Skip to content

Commit 9f022de

Browse files
committed
Avoid using len(x) to check if x is empty
1 parent 19c15a8 commit 9f022de

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

pygccxml/declarations/enumeration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def append_value(self, valuename, valuenum=None):
101101
"""
102102
# No number given? Then use the previous one + 1
103103
if valuenum is None:
104-
if len(self._values) == 0:
104+
if not self._values:
105105
valuenum = 0
106106
else:
107107
valuenum = self._values[-1][1] + 1

pygccxml/declarations/matcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def get_single(decl_matcher, decls, recursive=True):
102102
answer = matcher.find(decl_matcher, decls, recursive)
103103
if len(answer) == 1:
104104
return answer[0]
105-
elif len(answer) == 0:
105+
elif not answer:
106106
raise matcher.declaration_not_found_t(decl_matcher)
107107
else:
108108
raise matcher.multiple_declarations_found_t(decl_matcher)

pygccxml/parser/directory_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ def update_id_counter(self):
515515
"""Update the `id_` counter so that it doesn't grow forever.
516516
"""
517517

518-
if len(self.__entries) == 0:
518+
if not self.__entries:
519519
self.__next_id = 1
520520
else:
521521
self.__next_id = max(self.__entries.keys()) + 1

pygccxml/parser/source_reader.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,12 @@ def __add_symbols(self, cmd):
227227
228228
"""
229229

230-
if len(self.__config.define_symbols) != 0:
230+
if self.__config.define_symbols:
231231
symbols = self.__config.define_symbols
232232
cmd.append(''.join(
233233
[' -D"%s"' % defined_symbol for defined_symbol in symbols]))
234-
if len(self.__config.undefine_symbols) != 0:
234+
235+
if self.__config.undefine_symbols:
235236
un_symbols = self.__config.undefine_symbols
236237
cmd.append(
237238
''.join([' -U"%s"' % undefined_symbol for

0 commit comments

Comments
 (0)