diff options
author | Michael Selik <mike@selik.org> | 2017-04-02 06:02:31 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2017-04-02 06:02:31 (GMT) |
commit | 11fa3c7cd1b151e302d4eee0369cafbaf151c8fb (patch) | |
tree | 73bd2a704aa1aeccf39d06d729826b48637b093d /Lib/lib2to3 | |
parent | 64c887ab3a400cf91bde4f0c5ef69eacc88bc5e1 (diff) | |
download | cpython-11fa3c7cd1b151e302d4eee0369cafbaf151c8fb.zip cpython-11fa3c7cd1b151e302d4eee0369cafbaf151c8fb.tar.gz cpython-11fa3c7cd1b151e302d4eee0369cafbaf151c8fb.tar.bz2 |
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
Diffstat (limited to 'Lib/lib2to3')
-rw-r--r-- | Lib/lib2to3/btm_matcher.py | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/Lib/lib2to3/btm_matcher.py b/Lib/lib2to3/btm_matcher.py index eabe1a7..3b78868 100644 --- a/Lib/lib2to3/btm_matcher.py +++ b/Lib/lib2to3/btm_matcher.py @@ -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 |