]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake/data_smart: Improve the way lazyassignment works
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Feb 2011 11:48:01 +0000 (11:48 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Feb 2011 11:48:01 +0000 (11:48 +0000)
Currently, if a variable has been set with ??= and the code looks it up
before the data finalisation phase, no value is found. This is causes
serious problems for anonymous python functions which manipulate data, or
for the fetcher revision handling code where revisions can be set with
??=.

There is also a significant performance implication for processing lazy
assignment in finalise.

Moving the check for a default value into getVarFlag addresses both
the timing issue and the performace. This change gives a 7% real time
performance improvement to parsing the Poky metadata. The cost of the
check at this point is minimal since we have all the data flags available.

This should also fix Yocto bug 752.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/data_smart.py
bitbake/lib/bb/parse/ast.py

index 83e6f70cd7f44ca4902cdaa0e3705b4da96aefd3..e76fbbf6ce666ba24e3fd99cd8990ec729b8a794 100644 (file)
@@ -298,6 +298,8 @@ class DataSmart(MutableMapping):
         if local_var:
             if flag in local_var:
                 value = copy.copy(local_var[flag])
+            elif flag == "content" and "defaultval" in local_var:
+                value = copy.copy(local_var["defaultval"])
         if expand and value:
             value = self.expand(value, None)
         return value
index 8fffe1e8f0133ed4cbaadaed798689b86a916e7a..b968db40b378378216aae3fd670153df4c2490a8 100644 (file)
@@ -115,9 +115,6 @@ class DataNode(AstNode):
         if 'flag' in groupd and groupd['flag'] != None:
             bb.data.setVarFlag(key, groupd['flag'], val, data)
         elif groupd["lazyques"]:
-            assigned = bb.data.getVar("__lazy_assigned", data) or []
-            assigned.append(key)
-            bb.data.setVar("__lazy_assigned", assigned, data)
             bb.data.setVarFlag(key, "defaultval", val, data)
         else:
             bb.data.setVar(key, val, data)
@@ -310,11 +307,6 @@ def handleInherit(statements, filename, lineno, m):
     statements.append(InheritNode(filename, lineno, classes.split()))
 
 def finalize(fn, d, variant = None):
-    for lazykey in bb.data.getVar("__lazy_assigned", d) or ():
-        if bb.data.getVar(lazykey, d) is None:
-            val = bb.data.getVarFlag(lazykey, "defaultval", d)
-            bb.data.setVar(lazykey, val, d)
-
     bb.data.expandKeys(d)
     bb.data.update_data(d)
     code = []