diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2022-09-07 14:59:47 -0700 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-11-30 16:23:29 -0500 |
commit | 2d349eae8cb6f1f3b61838dca7cc989e9278be28 (patch) | |
tree | bc8d6325543e0df74b16941996f07797a746a2f6 /mesonbuild/cmake | |
parent | 50f35039e7df321a309ee45db57d37635bf53ce3 (diff) | |
download | meson-2d349eae8cb6f1f3b61838dca7cc989e9278be28.zip meson-2d349eae8cb6f1f3b61838dca7cc989e9278be28.tar.gz meson-2d349eae8cb6f1f3b61838dca7cc989e9278be28.tar.bz2 |
pylint: enable the set_membership plugin
Which adds the `use-set-for-membership` check. It's generally faster in
python to use a set with the `in` keyword, because it's a hash check
instead of a linear walk, this is especially true with strings, where
it's actually O(n^2), one loop over the container, and an inner loop of
the strings (as string comparison works by checking that `a[n] == b[n]`,
in a loop).
Also, I'm tired of complaining about this in reviews, let the tools do
it for me :)
Diffstat (limited to 'mesonbuild/cmake')
-rw-r--r-- | mesonbuild/cmake/common.py | 4 | ||||
-rw-r--r-- | mesonbuild/cmake/generator.py | 2 | ||||
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 6 | ||||
-rw-r--r-- | mesonbuild/cmake/traceparser.py | 6 |
4 files changed, 9 insertions, 9 deletions
diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py index 85598da..dffdbdf 100644 --- a/mesonbuild/cmake/common.py +++ b/mesonbuild/cmake/common.py @@ -100,9 +100,9 @@ def _flags_to_list(raw: str) -> T.List[str]: escape = False elif i == '\\': escape = True - elif i in ['"', "'"]: + elif i in {'"', "'"}: in_string = not in_string - elif i in [' ', '\n']: + elif i in {' ', '\n'}: if in_string: curr += i else: diff --git a/mesonbuild/cmake/generator.py b/mesonbuild/cmake/generator.py index d7a281a..9c9fa1c 100644 --- a/mesonbuild/cmake/generator.py +++ b/mesonbuild/cmake/generator.py @@ -99,7 +99,7 @@ def parse_generator_expressions( supported = { # Boolean functions - 'BOOL': lambda x: '0' if x.upper() in ['0', 'FALSE', 'OFF', 'N', 'NO', 'IGNORE', 'NOTFOUND'] or x.endswith('-NOTFOUND') else '1', + 'BOOL': lambda x: '0' if x.upper() in {'0', 'FALSE', 'OFF', 'N', 'NO', 'IGNORE', 'NOTFOUND'} or x.endswith('-NOTFOUND') else '1', 'AND': lambda x: '1' if all(y == '1' for y in x.split(',')) else '0', 'OR': lambda x: '1' if any(y == '1' for y in x.split(',')) else '0', 'NOT': lambda x: '0' if x == '1' else '1', diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index f96333a..f453aa3 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -320,7 +320,7 @@ class ConverterTarget: ) continue self.override_options += [f'{i}_std={std}'] - elif j in ['-fPIC', '-fpic', '-fPIE', '-fpie']: + elif j in {'-fPIC', '-fpic', '-fPIE', '-fpie'}: self.pie = True elif isinstance(ctgt, ConverterCustomTarget): # Sometimes projects pass generated source files as compiler @@ -1173,10 +1173,10 @@ class CMakeInterpreter: src_node = assign(src_var, function('files', sources)) tgt_node = assign(tgt_var, function(tgt_func, [tgt_var, id_node(src_var), *generated], tgt_kwargs)) node_list += [src_node, tgt_node] - if tgt_func in ['static_library', 'shared_library']: + if tgt_func in {'static_library', 'shared_library'}: dep_node = assign(dep_var, function('declare_dependency', kwargs=dep_kwargs)) node_list += [dep_node] - elif tgt_func in ['shared_module']: + elif tgt_func == 'shared_module': del dep_kwargs['link_with'] dep_node = assign(dep_var, function('declare_dependency', kwargs=dep_kwargs)) node_list += [dep_node] diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py index ef8ea39..e5aea8e 100644 --- a/mesonbuild/cmake/traceparser.py +++ b/mesonbuild/cmake/traceparser.py @@ -682,14 +682,14 @@ class CMakeTraceParser: if i in ignore: continue - if i in ['INTERFACE', 'LINK_INTERFACE_LIBRARIES', 'PUBLIC', 'PRIVATE', 'LINK_PUBLIC', 'LINK_PRIVATE']: + if i in {'INTERFACE', 'LINK_INTERFACE_LIBRARIES', 'PUBLIC', 'PRIVATE', 'LINK_PUBLIC', 'LINK_PRIVATE'}: mode = i continue - if mode in ['INTERFACE', 'LINK_INTERFACE_LIBRARIES', 'PUBLIC', 'LINK_PUBLIC']: + if mode in {'INTERFACE', 'LINK_INTERFACE_LIBRARIES', 'PUBLIC', 'LINK_PUBLIC'}: interface += i.split(';') - if mode in ['PUBLIC', 'PRIVATE', 'LINK_PRIVATE']: + if mode in {'PUBLIC', 'PRIVATE', 'LINK_PRIVATE'}: private += i.split(';') if paths: |