diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-11-28 23:42:30 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-11-29 10:24:09 +0000 |
commit | b4a8e5071dbcba2217b79e83e08b275ffcbc0eef (patch) | |
tree | 13ac0b651826682f674390a259c00285f8680a94 | |
parent | a4693b70764bb394ee2cf8dd12a5f6fce866008b (diff) | |
download | bitbake-b4a8e5071dbcba2217b79e83e08b275ffcbc0eef.tar.gz |
data_smart: Small cache reuse optimization
Currently the expand cache doesn't work for "parser" return types, which
is the main type used by the build_dependencies() call that we spend most
of the time in when parsing. Tweak the code to cache the unexpanded value
in the expand cache and hence allow reuse of the parser in other fast path
cases for small speed gains.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/data_smart.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index 246c446e4..e2c93597e 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -92,10 +92,11 @@ def infer_caller_details(loginfo, parent = False, varval = True): loginfo['func'] = func class VariableParse: - def __init__(self, varname, d, val = None): + def __init__(self, varname, d, unexpanded_value = None, val = None): self.varname = varname self.d = d self.value = val + self.unexpanded_value = unexpanded_value self.references = set() self.execs = set() @@ -447,9 +448,9 @@ class DataSmart(MutableMapping): def expandWithRefs(self, s, varname): if not isinstance(s, str): # sanity check - return VariableParse(varname, self, s) + return VariableParse(varname, self, s, s) - varparse = VariableParse(varname, self) + varparse = VariableParse(varname, self, s) while s.find('${') != -1: olds = s @@ -775,6 +776,9 @@ class DataSmart(MutableMapping): return None cachename = var + "[" + flag + "]" + if not expand and retparser and cachename in self.expand_cache: + return self.expand_cache[cachename].unexpanded_value, self.expand_cache[cachename] + if expand and cachename in self.expand_cache: return self.expand_cache[cachename].value |