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(
200
200
keys : Tuple [Node , ...] = (root ,)
201
201
idx = - 1
202
202
edits : List [Any ] = []
203
+ node : Any = root
204
+ key : Any = None
203
205
parent : Any = None
204
206
path : List [Any ] = []
205
207
path_append = path .append
206
208
path_pop = path .pop
207
209
ancestors : List [Any ] = []
208
210
ancestors_append = ancestors .append
209
211
ancestors_pop = ancestors .pop
210
- new_root = root
211
212
212
213
while True :
213
214
idx += 1
214
215
is_leaving = idx == len (keys )
215
216
is_edited = is_leaving and edits
216
217
if is_leaving :
217
218
key = path [- 1 ] if ancestors else None
218
- node : Any = parent
219
+ node = parent
219
220
parent = ancestors_pop () if ancestors else None
220
221
if is_edited :
221
222
if in_array :
@@ -238,21 +239,16 @@ def visit(
238
239
edits = stack .edits
239
240
in_array = stack .in_array
240
241
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 ]
249
246
else :
250
- key = None
251
- node = new_root
247
+ key = keys [ idx ]
248
+ node = getattr ( parent , key , None )
252
249
if node is None :
253
250
continue
254
- if parent :
255
- path_append (key )
251
+ path_append (key )
256
252
257
253
if isinstance (node , tuple ):
258
254
result = None
@@ -303,9 +299,9 @@ def visit(
303
299
break
304
300
305
301
if edits :
306
- new_root = edits [- 1 ][1 ]
302
+ return edits [- 1 ][1 ]
307
303
308
- return new_root
304
+ return root
309
305
310
306
311
307
class ParallelVisitor (Visitor ):
You can’t perform that action at this time.
0 commit comments