diff options
author | Dylan Baker <[email protected]> | 2018-10-24 12:30:03 -0700 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-10-31 16:37:46 -0700 |
commit | 465cfcb2663fa732041627e5a35c6cadb7851e75 (patch) | |
tree | 972587a7158c32bbc172c82a237446e94c77418f /src | |
parent | b9cd81ea3189ffdf847377ebbc11a676dc302a6f (diff) |
util/gen_xmlpool: Don't use len to test for container emptiness
This is a very common python anti-pattern. Not using length allows us to
go through faster C paths, but has the same meaning.
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/util/xmlpool/gen_xmlpool.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util/xmlpool/gen_xmlpool.py b/src/util/xmlpool/gen_xmlpool.py index 078bced7339..f1983c72514 100644 --- a/src/util/xmlpool/gen_xmlpool.py +++ b/src/util/xmlpool/gen_xmlpool.py @@ -182,7 +182,7 @@ def main(): with io.open(args.template, mode="rt", encoding='utf-8') as template: descMatches = [] for line in template: - if len(descMatches) > 0: + if descMatches: matchENUM = reENUM.match(line) matchDESC_END = reDESC_END.match(line) if matchENUM: @@ -201,16 +201,16 @@ def main(): matchDESC = reDESC.match(line) matchDESC_BEGIN = reDESC_BEGIN.match(line) if matchDESC: - assert len(descMatches) == 0 + assert not descMatches expandMatches([matchDESC], translations, output) elif matchDESC_BEGIN: - assert len(descMatches) == 0 + assert not descMatches descMatches = [matchDESC_BEGIN] else: output.write(line) - if len(descMatches) > 0: + if descMatches: print("Warning: unterminated description at end of file.", file=sys.stderr) expandMatches(descMatches, translations, output) |