bpo-29957: change LBYL key lookup to dict.setdefault (#938)
* change LBYL key lookup to dict.setdefault The ``results`` was constructed as a defaultdict and we could simply delete the check ``if key not in results``. However, I think it's safer to use dict.setdefault as I'm not sure whether the caller expects a regular dict or defaultdict. * add name to the acknowledgements file * use defaultdict to make the key-lookup cleaner
This commit is contained in:
parent
64c887ab3a
commit
11fa3c7cd1
|
@ -117,10 +117,7 @@ class BottomMatcher(object):
|
|||
#token matches
|
||||
current_ac_node = current_ac_node.transition_table[node_token]
|
||||
for fixer in current_ac_node.fixers:
|
||||
if not fixer in results:
|
||||
results[fixer] = []
|
||||
results[fixer].append(current_ast_node)
|
||||
|
||||
else:
|
||||
#matching failed, reset automaton
|
||||
current_ac_node = self.root
|
||||
|
@ -134,8 +131,6 @@ class BottomMatcher(object):
|
|||
#token matches
|
||||
current_ac_node = current_ac_node.transition_table[node_token]
|
||||
for fixer in current_ac_node.fixers:
|
||||
if not fixer in results.keys():
|
||||
results[fixer] = []
|
||||
results[fixer].append(current_ast_node)
|
||||
|
||||
current_ast_node = current_ast_node.parent
|
||||
|
|
Loading…
Reference in New Issue