Skip to content

Commit

Permalink
unwarper: replace falses array with a set
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrian Nord authored and Andrian Nord committed Jan 24, 2014
1 parent bffbbbc commit 2c8a703
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ljd/ast/unwarper.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ def _extract_if_expression(start, body, end, topmost_end):
expression = [start] + body[:i]
body = body[i:]

falses = []
falses = set()

for i, block in enumerate(body[:-1]):
if not isinstance(block.warp, nodes.UnconditionalWarp):
Expand All @@ -832,14 +832,13 @@ def _extract_if_expression(start, body, end, topmost_end):
if block.warp.target != end and block.warp.target != topmost_end:
continue

falses.append(body[i + 1])
falses.add(body[i + 1])

falses.append(end)
falses.add(end)

if topmost_end is not None:
falses.append(topmost_end)
falses.add(topmost_end)

falses = set(falses)
false, end_i = _search_expression_end(expression, falses)

assert end_i >= 0
Expand Down

0 comments on commit 2c8a703

Please sign in to comment.