Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions samtranslator/translator/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,15 @@ def _get_function_names(
)
if not resolved_function_name:
continue
self.function_names.setdefault(api_name, "")
self.function_names[api_name] += str(resolved_function_name)
return self.function_names
# OLD APPROACH: String concatenation in loop
# self.function_names.setdefault(api_name, "")
# self.function_names[api_name] += str(resolved_function_name)
# NEW APPROACH: Collect in list
Comment thread
roger-zhangg marked this conversation as resolved.
Outdated
if api_name not in self.function_names:
self.function_names[api_name]=[]
Comment thread
roger-zhangg marked this conversation as resolved.
Outdated
self.function_names[api_name].append(str(resolved_function_name))
#backward compatibility
Comment thread
roger-zhangg marked this conversation as resolved.
Outdated
return {api: "".join(names) for api, names in self.function_names.items()}

def translate( # noqa: PLR0912, PLR0915
self,
Expand All @@ -127,7 +133,9 @@ def translate( # noqa: PLR0912, PLR0915
self.feature_toggle = feature_toggle or FeatureToggle(
FeatureToggleDefaultConfigProvider(), stage=None, account_id=None, region=None
)
self.function_names: Dict[Any, Any] = {}
# OLD: self.function_names: Dict[Any, Any] = {}
# NEW: Use List[str] for efficient accumulation, convert to str when needed
Comment thread
roger-zhangg marked this conversation as resolved.
Outdated
self.function_names: Dict[str, List[str]] = {}
self.redeploy_restapi_parameters = {}
sam_parameter_values = SamParameterValues(parameter_values)
sam_parameter_values.add_default_parameter_values(sam_template)
Expand Down
Loading