diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2022-09-07 15:23:42 -0700 |
---|---|---|
committer | Eli Schwartz <eschwartz@archlinux.org> | 2022-10-04 00:33:04 -0400 |
commit | a72840cd2e27bf18b88cf95ef6a9e5e3ab05427d (patch) | |
tree | c3e6ce969bd01ae144f14213dd591e022c453019 /mesonbuild/cmake/interpreter.py | |
parent | f11ebf20ff51dc1e9d6aa07fea64bc891869e48a (diff) | |
download | meson-a72840cd2e27bf18b88cf95ef6a9e5e3ab05427d.zip meson-a72840cd2e27bf18b88cf95ef6a9e5e3ab05427d.tar.gz meson-a72840cd2e27bf18b88cf95ef6a9e5e3ab05427d.tar.bz2 |
pylint: enable use-a-generator
This catches some optimization problems, mostly in the use of `all()`
and `any()`. Basically writing `any([x == 5 for x in f])` vs `any(x == 5
for x in f)` reduces the performance because the entire concrete list
must first be created, then iterated over, while in the second f is
iterated and checked element by element.
Diffstat (limited to 'mesonbuild/cmake/interpreter.py')
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index b15b48d..dc63942 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -372,8 +372,8 @@ class ConverterTarget: for i in self.languages: supported += list(lang_suffixes[i]) supported = [f'.{x}' for x in supported] - self.sources = [x for x in self.sources if any([x.name.endswith(y) for y in supported])] - self.generated_raw = [x for x in self.generated_raw if any([x.name.endswith(y) for y in supported])] + self.sources = [x for x in self.sources if any(x.name.endswith(y) for y in supported)] + self.generated_raw = [x for x in self.generated_raw if any(x.name.endswith(y) for y in supported)] # Make paths relative def rel_path(x: Path, is_header: bool, is_generated: bool) -> T.Optional[Path]: @@ -381,7 +381,7 @@ class ConverterTarget: x = self.src_dir / x x = x.resolve() assert x.is_absolute() - if not x.exists() and not any([x.name.endswith(y) for y in obj_suffixes]) and not is_generated: + if not x.exists() and not any(x.name.endswith(y) for y in obj_suffixes) and not is_generated: if path_is_in_root(x, Path(self.env.get_build_dir()), resolve=True): x.mkdir(parents=True, exist_ok=True) return x.relative_to(Path(self.env.get_build_dir()) / subdir) @@ -471,7 +471,7 @@ class ConverterTarget: def process_object_libs(self, obj_target_list: T.List['ConverterTarget'], linker_workaround: bool) -> None: # Try to detect the object library(s) from the generated input sources - temp = [x for x in self.generated if any([x.name.endswith('.' + y) for y in obj_suffixes])] + temp = [x for x in self.generated if any(x.name.endswith('.' + y) for y in obj_suffixes)] stem = [x.stem for x in temp] exts = self._all_source_suffixes() # Temp now stores the source filenames of the object files @@ -484,10 +484,10 @@ class ConverterTarget: # undo this step and guess the correct language suffix of the object file. This is done # by trying all language suffixes meson knows and checking if one of them fits. candidates = [j] # type: T.List[str] - if not any([j.endswith('.' + x) for x in exts]): + if not any(j.endswith('.' + x) for x in exts): mlog.warning('Object files do not contain source file extensions, thus falling back to guessing them.', once=True) candidates += [f'{j}.{x}' for x in exts] - if any([x in source_files for x in candidates]): + if any(x in source_files for x in candidates): if linker_workaround: self._append_objlib_sources(i) else: @@ -497,7 +497,7 @@ class ConverterTarget: break # Filter out object files from the sources - self.generated = [x for x in self.generated if not any([x.name.endswith('.' + y) for y in obj_suffixes])] + self.generated = [x for x in self.generated if not any(x.name.endswith('.' + y) for y in obj_suffixes)] def _append_objlib_sources(self, tgt: 'ConverterTarget') -> None: self.includes += tgt.includes |