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:25:51 +0000 |
commit | 43ef392dc2e85c2f298fdb1ee970708c4c2e79f9 (patch) | |
tree | d817d7a9f147d8c013e51b4762acc8b73a02addb /bitbake/lib | |
parent | 70a7e7337bb62bc511972f710fd56a5ac627c8cc (diff) | |
download | poky-43ef392dc2e85c2f298fdb1ee970708c4c2e79f9.tar.gz |
bitbake: 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.
(Bitbake rev: b4a8e5071dbcba2217b79e83e08b275ffcbc0eef)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 246c446e4a..e2c93597e5 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -92,10 +92,11 @@ def infer_caller_details(loginfo, parent = False, varval = True): | |||
92 | loginfo['func'] = func | 92 | loginfo['func'] = func |
93 | 93 | ||
94 | class VariableParse: | 94 | class VariableParse: |
95 | def __init__(self, varname, d, val = None): | 95 | def __init__(self, varname, d, unexpanded_value = None, val = None): |
96 | self.varname = varname | 96 | self.varname = varname |
97 | self.d = d | 97 | self.d = d |
98 | self.value = val | 98 | self.value = val |
99 | self.unexpanded_value = unexpanded_value | ||
99 | 100 | ||
100 | self.references = set() | 101 | self.references = set() |
101 | self.execs = set() | 102 | self.execs = set() |
@@ -447,9 +448,9 @@ class DataSmart(MutableMapping): | |||
447 | def expandWithRefs(self, s, varname): | 448 | def expandWithRefs(self, s, varname): |
448 | 449 | ||
449 | if not isinstance(s, str): # sanity check | 450 | if not isinstance(s, str): # sanity check |
450 | return VariableParse(varname, self, s) | 451 | return VariableParse(varname, self, s, s) |
451 | 452 | ||
452 | varparse = VariableParse(varname, self) | 453 | varparse = VariableParse(varname, self, s) |
453 | 454 | ||
454 | while s.find('${') != -1: | 455 | while s.find('${') != -1: |
455 | olds = s | 456 | olds = s |
@@ -775,6 +776,9 @@ class DataSmart(MutableMapping): | |||
775 | return None | 776 | return None |
776 | cachename = var + "[" + flag + "]" | 777 | cachename = var + "[" + flag + "]" |
777 | 778 | ||
779 | if not expand and retparser and cachename in self.expand_cache: | ||
780 | return self.expand_cache[cachename].unexpanded_value, self.expand_cache[cachename] | ||
781 | |||
778 | if expand and cachename in self.expand_cache: | 782 | if expand and cachename in self.expand_cache: |
779 | return self.expand_cache[cachename].value | 783 | return self.expand_cache[cachename].value |
780 | 784 | ||