summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorChris Larson <clarson@mvista.com>2009-06-11 13:10:04 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2010-03-22 15:01:59 +0000
commitada2a8494a88b59de25c0a44fce30190f560eff4 (patch)
tree67f60f7ae769b74815757e45c12e4d694270a802 /bitbake/lib/bb/data_smart.py
parent9d9b47bae4b880ec57eda0e647b1d24fbc3ba3cf (diff)
downloadpoky-ada2a8494a88b59de25c0a44fce30190f560eff4.tar.gz
Avoid unnecessary calls to keys() when iterating over dictionaries.
dict objects provide an __iter__ method for the iteration which gives you the keys, so calling keys directly is unnecessary, and isn't really a best practice. The only time you really need to call the keys is if there's a danger of the dict changing out from underneith you, either due to external forces or due to modification of the iterable in the loop. Iterations over os.environ are apparently subject to such changes, so they must continue to use keys(). As an aside, also switches a couple spots to using sorted() rather than creating a temporary list with keys() and sorting that. (Bitbake rev: 5b6ccb16c6e71e23dac6920cd2df994d67c2587b) Signed-off-by: Chris Larson <clarson@mvista.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/data_smart.py')
-rw-r--r--bitbake/lib/bb/data_smart.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index 988d5c3578..dac7fb705e 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -219,7 +219,7 @@ class DataSmart:
219 if not var in self.dict: 219 if not var in self.dict:
220 self._makeShadowCopy(var) 220 self._makeShadowCopy(var)
221 221
222 for i in flags.keys(): 222 for i in flags:
223 if i == "content": 223 if i == "content":
224 continue 224 continue
225 self.dict[var][i] = flags[i] 225 self.dict[var][i] = flags[i]
@@ -229,7 +229,7 @@ class DataSmart:
229 flags = {} 229 flags = {}
230 230
231 if local_var: 231 if local_var:
232 for i in local_var.keys(): 232 for i in local_var:
233 if i == "content": 233 if i == "content":
234 continue 234 continue
235 flags[i] = local_var[i] 235 flags[i] = local_var[i]