From c6060d795cfc9084505123bbb4004ccb112f0de3 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 4 Apr 2019 13:35:43 -0700 Subject: [PATCH] coredata: remove get_builtin_options This returns a list out of th keys of a dict. In both cases of use remaining though it's used for checking membership, checking for list membership, lists are O(n) lookup, while dicts are O(1), so removing the abstraction reduces typing and improves performance. --- mesonbuild/coredata.py | 7 ++----- mesonbuild/optinterpreter.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 9002fd931..97094fbfb 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -508,7 +508,7 @@ class CoreData: if subproject: if not k.startswith(subproject + ':'): continue - elif k not in get_builtin_options(): + elif k not in builtin_options: if ':' in k: continue if optinterpreter.is_invalid_name(k): @@ -654,11 +654,8 @@ def save(obj, build_dir): os.replace(tempfilename, filename) return filename -def get_builtin_options(): - return list(builtin_options.keys()) - def is_builtin_option(optname): - return optname in get_builtin_options() + return optname in builtin_options def get_builtin_option_choices(optname): if is_builtin_option(optname): diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index 85f68976f..2d60d102b 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -20,7 +20,7 @@ from . import coredata from . import mesonlib from . import compilers -forbidden_option_names = coredata.get_builtin_options() +forbidden_option_names = set(coredata.builtin_options.keys()) forbidden_prefixes = [lang + '_' for lang in compilers.all_languages] + ['b_', 'backend_'] reserved_prefixes = ['cross_']