Skip to contentSkip to conversation

data: Move warning code to the first loop for performance

PATCH In review Richard Purdie 2 participants 3 messages May 25, 2015 – May 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 data: Move warning code to the first loop for performance

By doing this we can take advantage of the expansion cache before starting write operations on the data store.

bitbake/lib/bb/data.py +5 -5
index 82eefef..218998a 100644
@@ -156,17 +156,17 @@ def expandKeys(alterdata, readdata = None):
         if key == ekey:
             continue
         todolist[key] = ekey
+        newval = alterdata.getVar(ekey, 0)
+        if newval:
+            val = alterdata.getVar(key, 0)
+            if val is not None and newval is not None:
+                bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval))
 
     # These two for loops are split for performance to maximise the
     # usefulness of the expand cache
 
     for key in todolist:
         ekey = todolist[key]
-        newval = alterdata.getVar(ekey, 0)
-        if newval:
-            val = alterdata.getVar(key, 0)
-            if val is not None and newval is not None:
-                bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval))
         alterdata.renameVar(key, ekey)
 
 def inheritFromOS(d, savedenv, permitted):
#1 lore raw
Quoted 10 lines · Richard Purdie

By doing this we can take advantage of the expansion cache before starting write operations on the data store.

bitbake/lib/bb/data.py +0 -0
index 82eefef..218998a 100644

bitbake/lib/bb/data.py def expandKeys(alterdata, readdata = None): · line 162

Quoted 7 lines
bitbake/lib/bb/data.py +4 -0
@@ -156,17 +156,17 @@ def expandKeys(alterdata, readdata = None):
        if key == ekey:
            continue
        todolist[key] = ekey
+        newval = alterdata.getVar(ekey, 0)
+        if newval:
+            val = alterdata.getVar(key, 0)
+            if val is not None and newval is not None:

newval cannot ever be None in this if.

Thanks,

Quoted 17 lines
bitbake/lib/bb/data.py +1 -5
+                bb.warn("Variable key %s (%s) replaces original key %s
 (%s)." % (key, val, ekey, newval))
 
    # These two for loops are split for performance to maximise the
    # usefulness of the expand cache
 
    for key in todolist:
        ekey = todolist[key]
-        newval = alterdata.getVar(ekey, 0)
-        if newval:
-            val = alterdata.getVar(key, 0)
-            if val is not None and newval is not None:
-                bb.warn("Variable key %s (%s) replaces original key %s
 (%s)." % (key, val, ekey, newval))
        alterdata.renameVar(key, ekey)

def inheritFromOS(d, savedenv, permitted):

#2 lore raw
Quoted 6 lines · Bernhard Reutner-Fischer
Quoted 5 lines · Richard Purdie

By doing this we can take advantage of the expansion cache before starting write operations on the data store.

Quoted 14 lines

bitbake/lib/bb/data.py def expandKeys(alterdata, readdata = None): · line 162

Quoted 12 lines
bitbake/lib/bb/data.py +4 -0
index 82eefef..218998a 100644
@@ -156,17 +156,17 @@ def expandKeys(alterdata, readdata = None):
        if key == ekey:
            continue
        todolist[key] = ekey
+        newval = alterdata.getVar(ekey, 0)
+        if newval:
+            val = alterdata.getVar(key, 0)
+            if val is not None and newval is not None:

newval cannot ever be None in this if.

True, to be fair I just moved the code although I probably was responsible for the original too.

I'll tweak it, thanks.

Cheers,

Richard