Skip to content

Commit

Permalink
Optimize wmliterator.isDirective()
Browse files Browse the repository at this point in the history
Skips an unecessary for loop and if conditional.
  • Loading branch information
legoktm committed Jul 27, 2015
1 parent de864c0 commit bd23c32
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions data/tools/wesnoth/wmliterator.py
Expand Up @@ -49,14 +49,13 @@ def wmlfindin(element, scopeElement, wmlItor):
return itor
return None


def isDirective(elem):
"Identify things that shouldn't be indented."
if isinstance(elem, WmlIterator):
elem = elem.element
for prefix in ("#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#ifver", "#ifnver", "#else", "#endif", "#define", "#enddef", "#undef"):
if elem.startswith(prefix):
return True
return False
return elem.startswith(("#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#ifver", "#ifnver", "#else", "#endif", "#define", "#enddef", "#undef"))


def isCloser(elem):
"Are we looking at a closing tag?"
Expand Down

0 comments on commit bd23c32

Please sign in to comment.