File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -200,22 +200,23 @@ def visit(
200200 keys : Tuple [Node , ...] = (root ,)
201201 idx = - 1
202202 edits : List [Any ] = []
203+ node : Any = root
204+ key : Any = None
203205 parent : Any = None
204206 path : List [Any ] = []
205207 path_append = path .append
206208 path_pop = path .pop
207209 ancestors : List [Any ] = []
208210 ancestors_append = ancestors .append
209211 ancestors_pop = ancestors .pop
210- new_root = root
211212
212213 while True :
213214 idx += 1
214215 is_leaving = idx == len (keys )
215216 is_edited = is_leaving and edits
216217 if is_leaving :
217218 key = path [- 1 ] if ancestors else None
218- node : Any = parent
219+ node = parent
219220 parent = ancestors_pop () if ancestors else None
220221 if is_edited :
221222 if in_array :
@@ -238,21 +239,16 @@ def visit(
238239 edits = stack .edits
239240 in_array = stack .in_array
240241 stack = stack .prev
241- else :
242- if parent :
243- if in_array :
244- key = idx
245- node = parent [key ]
246- else :
247- key = keys [idx ]
248- node = getattr (parent , key , None )
242+ elif parent :
243+ if in_array :
244+ key = idx
245+ node = parent [key ]
249246 else :
250- key = None
251- node = new_root
247+ key = keys [ idx ]
248+ node = getattr ( parent , key , None )
252249 if node is None :
253250 continue
254- if parent :
255- path_append (key )
251+ path_append (key )
256252
257253 if isinstance (node , tuple ):
258254 result = None
@@ -303,9 +299,9 @@ def visit(
303299 break
304300
305301 if edits :
306- new_root = edits [- 1 ][1 ]
302+ return edits [- 1 ][1 ]
307303
308- return new_root
304+ return root
309305
310306
311307class ParallelVisitor (Visitor ):
You can’t perform that action at this time.
0 commit comments