From cc2a8ff5225e9fe987d8036970b2bf4293a13611 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 10 Jun 2011 17:23:33 +0100 Subject: 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. (Bitbake rev: 9d43e3279895639ee4899df635f2546c7ee13737) Signed-off-by: Richard Purdie --- bitbake/lib/bb/data_smart.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'bitbake/lib/bb/data_smart.py') diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 93c1b81aee..1fede8f01e 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/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)) -- cgit v1.2.3-54-g00ecf