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:
Michael Selik 2017-04-02 02:02:31 -04:00 committed by Benjamin Peterson
parent 64c887ab3a
commit 11fa3c7cd1
2 changed files with 1 additions and 5 deletions

View File

@ -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

View File

@ -1376,6 +1376,7 @@ Steven Scott
Nick Seidenman
Michael Seifert
Žiga Seilnacht
Michael Selik
Yury Selivanov
Fred Sells
Jiwon Seo