summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.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/cooker.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/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 5f9becccac..938bdeaaea 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -219,18 +219,15 @@ class BBCooker:
219 latest_versions = {} 219 latest_versions = {}
220 220
221 # Sort by priority 221 # Sort by priority
222 for pn in pkg_pn.keys(): 222 for pn in pkg_pn:
223 (last_ver,last_file,pref_ver,pref_file) = bb.providers.findBestProvider(pn, self.configuration.data, self.status) 223 (last_ver,last_file,pref_ver,pref_file) = bb.providers.findBestProvider(pn, self.configuration.data, self.status)
224 preferred_versions[pn] = (pref_ver, pref_file) 224 preferred_versions[pn] = (pref_ver, pref_file)
225 latest_versions[pn] = (last_ver, last_file) 225 latest_versions[pn] = (last_ver, last_file)
226 226
227 pkg_list = pkg_pn.keys()
228 pkg_list.sort()
229
230 bb.msg.plain("%-35s %25s %25s" % ("Package Name", "Latest Version", "Preferred Version")) 227 bb.msg.plain("%-35s %25s %25s" % ("Package Name", "Latest Version", "Preferred Version"))
231 bb.msg.plain("%-35s %25s %25s\n" % ("============", "==============", "=================")) 228 bb.msg.plain("%-35s %25s %25s\n" % ("============", "==============", "================="))
232 229
233 for p in pkg_list: 230 for p in sorted(pkg_pn):
234 pref = preferred_versions[p] 231 pref = preferred_versions[p]
235 latest = latest_versions[p] 232 latest = latest_versions[p]
236 233
@@ -487,7 +484,7 @@ class BBCooker:
487 self.status.preferred[providee] = provider 484 self.status.preferred[providee] = provider
488 485
489 # Calculate priorities for each file 486 # Calculate priorities for each file
490 for p in self.status.pkg_fn.keys(): 487 for p in self.status.pkg_fn:
491 self.status.bbfile_priority[p] = calc_bbfile_priority(p) 488 self.status.bbfile_priority[p] = calc_bbfile_priority(p)
492 489
493 def buildWorldTargetList(self): 490 def buildWorldTargetList(self):