From ada2a8494a88b59de25c0a44fce30190f560eff4 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 11 Jun 2009 13:10:04 -0700 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/data_smart.py | 4 ++-- 1 file changed, 2 insertions(+), 2 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 988d5c3578..dac7fb705e 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py @@ -219,7 +219,7 @@ class DataSmart: if not var in self.dict: self._makeShadowCopy(var) - for i in flags.keys(): + for i in flags: if i == "content": continue self.dict[var][i] = flags[i] @@ -229,7 +229,7 @@ class DataSmart: flags = {} if local_var: - for i in local_var.keys(): + for i in local_var: if i == "content": continue flags[i] = local_var[i] -- cgit v1.2.3-54-g00ecf