Skip to content

Commit 978924d

Browse files
Apply suggestion from @codeflash-ai[bot]
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
1 parent 5891dfa commit 978924d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

codeflash/code_utils/deduplicate_code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ def visit_Global(self, node): # noqa : ANN001, ANN201
7070
self.global_vars.update(node.names)
7171
return node
7272

73-
def visit_Nonlocal(self, node): # noqa : ANN001, ANN201
73+
def visit_Nonlocal(self, node):
7474
"""Track nonlocal variable declarations."""
75-
for name in node.names:
76-
self.nonlocal_vars.add(name)
75+
# Using set.update for batch insertion (faster than add-in-loop)
76+
self.nonlocal_vars.update(node.names)
7777
return node
7878

7979
def visit_FunctionDef(self, node): # noqa : ANN001, ANN201

0 commit comments

Comments
 (0)