summaryrefslogtreecommitdiffstats
path: root/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-03 12:10:05 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-03 12:44:49 +0000
commitfca802187a2a30686a8a07d2b6b16a3e5716e293 (patch)
treeb8b61ace84f1afba8f74d5304eb8e3c994210397 /lib/bb/data_smart.py
parent78ad15b669b9c7cde41f7bd1ab884c1d2e0db91b (diff)
downloadbitbake-contrib-fca802187a2a30686a8a07d2b6b16a3e5716e293.tar.gz
codeparser/data_smart: Optimise parsing speed
The previous "contains" changes caused a ~3% parsing speed impact. Looking at the cause of those changes was interesting: * Use of defaultdict was slower than just checking for missing entries and setting them when needed. * Even the "import collections" adversely affects parsing speed * There was a missing intern function for the contains cache data * Setting up a log object for each variable has noticeable overhead due to the changes in the code paths uses, we can avoid this. * We can call getVarFlag on "_content" directly within VariableParse for a noticeable speed gain since its a seriously hot code path. This patch therefore tweaks the code based on the above observations to get some of the speed back. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/data_smart.py')
-rw-r--r--lib/bb/data_smart.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 9a6f76711..833d9f17a 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -35,7 +35,6 @@ import hashlib
import bb, bb.codeparser
from bb import utils
from bb.COW import COWDictBase
-import collections
logger = logging.getLogger("BitBake.Data")
@@ -89,7 +88,7 @@ class VariableParse:
self.references = set()
self.execs = set()
- self.contains = collections.defaultdict(set)
+ self.contains = {}
def var_sub(self, match):
key = match.group()[2:-1]
@@ -100,7 +99,7 @@ class VariableParse:
varparse = self.d.expand_cache[key]
var = varparse.value
else:
- var = self.d.getVar(key, True)
+ var = self.d.getVarFlag(key, "_content", True)
self.references.add(key)
if var is not None:
return var
@@ -123,7 +122,10 @@ class VariableParse:
self.execs |= parser.execs
for k in parser.contains:
- self.contains[k].update(parser.contains[k])
+ if k not in self.contains:
+ self.contains[k] = parser.contains[k]
+ else:
+ self.contains[k].update(parser.contains[k])
value = utils.better_eval(codeobj, DataContext(self.d))
return str(value)