aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers
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/compilers
parent50f35039e7df321a309ee45db57d37635bf53ce3 (diff)
downloadmeson-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/compilers')
-rw-r--r--mesonbuild/compilers/cuda.py2
-rw-r--r--mesonbuild/compilers/d.py2
-rw-r--r--mesonbuild/compilers/fortran.py4
-rw-r--r--mesonbuild/compilers/java.py2
-rw-r--r--mesonbuild/compilers/mixins/clike.py2
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py6
6 files changed, 9 insertions, 9 deletions
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py
index 46a86b7..25a7baf 100644
--- a/mesonbuild/compilers/cuda.py
+++ b/mesonbuild/compilers/cuda.py
@@ -747,7 +747,7 @@ class CudaCompiler(Compiler):
# native option to override it; override it with /NODEFAULTLIB
host_link_arg_overrides = []
host_crt_compile_args = self.host_compiler.get_crt_compile_args(crt_val, buildtype)
- if any(arg in ['/MDd', '/MD', '/MTd'] for arg in host_crt_compile_args):
+ if any(arg in {'/MDd', '/MD', '/MTd'} for arg in host_crt_compile_args):
host_link_arg_overrides += ['/NODEFAULTLIB:LIBCMT.lib']
return self._to_host_flags(host_link_arg_overrides + self.host_compiler.get_crt_link_args(crt_val, buildtype), _Phase.LINKER)
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index cd67d5a..90c0498 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -463,7 +463,7 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
if crt_val in self.mscrt_args:
return self.mscrt_args[crt_val]
- assert crt_val in ['from_buildtype', 'static_from_buildtype']
+ assert crt_val in {'from_buildtype', 'static_from_buildtype'}
dbg = 'mdd'
rel = 'md'
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index b82b2ff..90ca010 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -105,9 +105,9 @@ class FortranCompiler(CLikeCompiler, Compiler):
def module_name_to_filename(self, module_name: str) -> str:
if '_' in module_name: # submodule
s = module_name.lower()
- if self.id in ('gcc', 'intel', 'intel-cl'):
+ if self.id in {'gcc', 'intel', 'intel-cl'}:
filename = s.replace('_', '@') + '.smod'
- elif self.id in ('pgi', 'flang'):
+ elif self.id in {'pgi', 'flang'}:
filename = s.replace('_', '-') + '.mod'
else:
filename = s + '.mod'
diff --git a/mesonbuild/compilers/java.py b/mesonbuild/compilers/java.py
index bfd9b1a..ebae509 100644
--- a/mesonbuild/compilers/java.py
+++ b/mesonbuild/compilers/java.py
@@ -75,7 +75,7 @@ class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler):
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str],
build_dir: str) -> T.List[str]:
for idx, i in enumerate(parameter_list):
- if i in ['-cp', '-classpath', '-sourcepath'] and idx + 1 < len(parameter_list):
+ if i in {'-cp', '-classpath', '-sourcepath'} and idx + 1 < len(parameter_list):
path_list = parameter_list[idx + 1].split(os.pathsep)
path_list = [os.path.normpath(os.path.join(build_dir, x)) for x in path_list]
parameter_list[idx + 1] = os.pathsep.join(path_list)
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index b4824d5..8736c6d 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -1320,7 +1320,7 @@ class CLikeCompiler(Compiler):
# don't work
m = env.machines[self.for_machine]
if not (m.is_windows() or m.is_cygwin()):
- if name in ['dllimport', 'dllexport']:
+ if name in {'dllimport', 'dllexport'}:
return False, False
return self.compiles(self.attribute_check_func(name), env,
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index d61ad42..765d63d 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -228,7 +228,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
for i in args:
# -mms-bitfields is specific to MinGW-GCC
# -pthread is only valid for GCC
- if i in ('-mms-bitfields', '-pthread'):
+ if i in {'-mms-bitfields', '-pthread'}:
continue
if i.startswith('-LIBPATH:'):
i = '/LIBPATH:' + i[9:]
@@ -361,7 +361,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]:
if crt_val in self.crt_args:
return self.crt_args[crt_val]
- assert crt_val in ['from_buildtype', 'static_from_buildtype']
+ assert crt_val in {'from_buildtype', 'static_from_buildtype'}
dbg = 'mdd'
rel = 'md'
if crt_val == 'static_from_buildtype':
@@ -385,7 +385,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
def has_func_attribute(self, name: str, env: 'Environment') -> T.Tuple[bool, bool]:
# MSVC doesn't have __attribute__ like Clang and GCC do, so just return
# false without compiling anything
- return name in ['dllimport', 'dllexport'], False
+ return name in {'dllimport', 'dllexport'}, False
def get_argument_syntax(self) -> str:
return 'msvc'