compilers/cpp: use a list comprehension instead of a for loop

It's slightly faster, and less code
pull/11924/head
Dylan Baker 1 year ago
parent 59cfbf68e0
commit a4b597a7b7
  1. 12
      mesonbuild/compilers/cpp.py

@ -254,9 +254,7 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler):
# be passed to a different compiler with a different set of default # 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 # search paths, such as when using Clang for C/C++ and gfortran for
# fortran, # fortran,
search_dirs: T.List[str] = [] search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(env, 'libraries')]
for d in self.get_compiler_dirs(env, 'libraries'):
search_dirs.append(f'-L{d}')
return search_dirs + ['-lstdc++'] return search_dirs + ['-lstdc++']
@ -271,9 +269,7 @@ class AppleClangCPPCompiler(ClangCPPCompiler):
# be passed to a different compiler with a different set of default # 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 # search paths, such as when using Clang for C/C++ and gfortran for
# fortran, # fortran,
search_dirs: T.List[str] = [] search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(env, 'libraries')]
for d in self.get_compiler_dirs(env, 'libraries'):
search_dirs.append(f'-L{d}')
return search_dirs + ['-lc++'] return search_dirs + ['-lc++']
@ -439,9 +435,7 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler):
# be passed to a different compiler with a different set of default # 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 # search paths, such as when using Clang for C/C++ and gfortran for
# fortran, # fortran,
search_dirs: T.List[str] = [] search_dirs = [f'-L{d}' for d in self.get_compiler_dirs(env, 'libraries')]
for d in self.get_compiler_dirs(env, 'libraries'):
search_dirs.append(f'-L{d}')
return search_dirs + ['-lstdc++'] return search_dirs + ['-lstdc++']

Loading…
Cancel
Save