summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-10 17:23:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-28 15:26:55 +0100
commit9d43e3279895639ee4899df635f2546c7ee13737 (patch)
tree9fa3c3586e462890e03e24142d97a216dec52301
parent41bef02bef8379590ba012319aebe05068a8081e (diff)
downloadbitbake-9d43e3279895639ee4899df635f2546c7ee13737.tar.gz
bitbake/data_smart: Optimise the data store iterator
Since we're going to creat the seen set() anyway, we might as well use it directly. If we don't do this, we see thousands of function calls with associated overhead on profiles. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/data_smart.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 93c1b81ae..1fede8f01 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -401,18 +401,20 @@ class DataSmart(MutableMapping):
yield key
def __iter__(self):
- seen = set()
- def _keys(d):
+ def keylist(d):
+ klist = set()
+ for key in d:
+ if key == "_data":
+ continue
+ klist.add(key)
+
if "_data" in d:
- for key in _keys(d["_data"]):
- yield key
+ klist |= keylist(d["_data"])
- for key in d:
- if key != "_data":
- if not key in seen:
- seen.add(key)
- yield key
- return _keys(self.dict)
+ return klist
+
+ for k in keylist(self.dict):
+ yield k
def __len__(self):
return len(frozenset(self))