summaryrefslogtreecommitdiff
path: root/mesonbuild/rewriter.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-09-07 14:59:47 -0700
committerEli Schwartz <eschwartz@archlinux.org>2022-11-30 16:23:29 -0500
commit2d349eae8cb6f1f3b61838dca7cc989e9278be28 (patch)
treebc8d6325543e0df74b16941996f07797a746a2f6 /mesonbuild/rewriter.py
parent50f35039e7df321a309ee45db57d37635bf53ce3 (diff)
downloadmeson-2d349eae8cb6f1f3b61838dca7cc989e9278be28.tar.gz
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/rewriter.py')
-rw-r--r--mesonbuild/rewriter.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py
index 7d4f989e0..8a1021cb5 100644
--- a/mesonbuild/rewriter.py
+++ b/mesonbuild/rewriter.py
@@ -420,7 +420,7 @@ class Rewriter:
if target in self.interpreter.assignments:
node = self.interpreter.assignments[target]
if isinstance(node, FunctionNode):
- if node.func_name in ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries']:
+ if node.func_name in {'executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries'}:
tgt = self.interpreter.assign_vals[target]
return tgt
@@ -440,7 +440,7 @@ class Rewriter:
if dependency in self.interpreter.assignments:
node = self.interpreter.assignments[dependency]
if isinstance(node, FunctionNode):
- if node.func_name in ['dependency']:
+ if node.func_name == 'dependency':
name = self.interpreter.flatten_args(node.args)[0]
dep = check_list(name)
@@ -952,15 +952,15 @@ class Rewriter:
while raw[end] != '=':
end += 1
end += 1 # Handle the '='
- while raw[end] in [' ', '\n', '\t']:
+ while raw[end] in {' ', '\n', '\t'}:
end += 1
files[i['file']]['raw'] = raw[:start] + i['str'] + raw[end:]
for i in str_list:
- if i['action'] in ['modify', 'rm']:
+ if i['action'] in {'modify', 'rm'}:
remove_node(i)
- elif i['action'] in ['add']:
+ elif i['action'] == 'add':
files[i['file']]['raw'] += i['str'] + '\n'
# Write the files back