aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-04-24 09:42:33 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2017-04-28 22:42:39 +0300
commit6944d06116bf3ed691faf991dbfa0478c8c2d345 (patch)
tree819625a2a51e380cf3bfd8a0074d17789a17834d
parent9635d0bd69e14e1647aae61b254e3848150dfbae (diff)
downloadmeson-6944d06116bf3ed691faf991dbfa0478c8c2d345.zip
meson-6944d06116bf3ed691faf991dbfa0478c8c2d345.tar.gz
meson-6944d06116bf3ed691faf991dbfa0478c8c2d345.tar.bz2
Don't use dict.keys() to check membership
It's much faster to do 'if a in dict' instead of 'if a in dict.keys()', since the latter constructs an iterator and walks that iterator and then tests equality at each step, and the former does a single hash lookup.
-rw-r--r--mesonbuild/environment.py2
-rw-r--r--mesonbuild/mesonlib.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index d3be926..b0ba78d 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -819,7 +819,7 @@ def get_args_from_envvars(compiler):
if hasattr(compiler, 'get_linker_exelist'):
compiler_is_linker = (compiler.get_exelist() == compiler.get_linker_exelist())
- if lang not in cflags_mapping.keys():
+ if lang not in cflags_mapping:
return [], [], []
compile_flags = os.environ.get(cflags_mapping[lang], '')
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 0263768..fbd732a 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -371,7 +371,7 @@ def do_replacement(regex, line, confdata):
match = re.search(regex, line)
while match:
varname = match.group(1)
- if varname in confdata.keys():
+ if varname in confdata:
(var, desc) = confdata.get(varname)
if isinstance(var, str):
pass