From a4b597a7b7b8c9d2129fbd93a985021c7d6742d6 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 29 Jun 2023 09:00:46 -0700 Subject: [PATCH] compilers/cpp: use a list comprehension instead of a for loop It's slightly faster, and less code --- mesonbuild/compilers/cpp.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 16e337b27..6eaa6c87e 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -254,9 +254,7 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler): # be passed to a different compiler with a different set of default # search paths, such as when using Clang for C/C++ and gfortran for # fortran, - search_dirs: T.List[str] = [] - for d in self.get_compiler_dirs(env, 'libraries'): - search_dirs.append(f'-L{d}') + search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(env, 'libraries')] return search_dirs + ['-lstdc++'] @@ -271,9 +269,7 @@ class AppleClangCPPCompiler(ClangCPPCompiler): # be passed to a different compiler with a different set of default # search paths, such as when using Clang for C/C++ and gfortran for # fortran, - search_dirs: T.List[str] = [] - for d in self.get_compiler_dirs(env, 'libraries'): - search_dirs.append(f'-L{d}') + search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(env, 'libraries')] return search_dirs + ['-lc++'] @@ -439,9 +435,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): # be passed to a different compiler with a different set of default # search paths, such as when using Clang for C/C++ and gfortran for # fortran, - search_dirs: T.List[str] = [] - for d in self.get_compiler_dirs(env, 'libraries'): - search_dirs.append(f'-L{d}') + search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(env, 'libraries')] return search_dirs + ['-lstdc++']