diff options
author | Bob Foerster <robert@erafx.com> | 2010-11-20 04:39:22 +0800 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-04 14:46:42 +0000 |
commit | c6328564de8e8cae113ee559d769105f9f4b6003 (patch) | |
tree | c557df9ea46a3ed9501e14829be7db0af09239a7 /bitbake/lib/bb/utils.py | |
parent | e81fc749f34df0b6944849f217840b3a7a027af8 (diff) | |
download | poky-c6328564de8e8cae113ee559d769105f9f4b6003.tar.gz |
Prefer xrange over range for small performance gain.
range() allocates an actual list when called. xrange() is just an iterator
and creates the next range item on demand. This provides a slight
performance increase.
In python 3, range will do what xrange does currently, but the upgrade will
be handled by the 2to3 tool.
(Bitbake rev: 73b40f06444cb877a5960b2aa66abf7dacbd88f0)
Signed-off-by: Bob Foerster <robert@erafx.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index f5336dda60..4208c79343 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -194,10 +194,10 @@ def vercmp_string(val1, val2): | |||
194 | val2 = val2[0].split('.') | 194 | val2 = val2[0].split('.') |
195 | 195 | ||
196 | # add back decimal point so that .03 does not become "3" ! | 196 | # add back decimal point so that .03 does not become "3" ! |
197 | for x in range(1, len(val1)): | 197 | for x in xrange(1, len(val1)): |
198 | if val1[x][0] == '0' : | 198 | if val1[x][0] == '0' : |
199 | val1[x] = '.' + val1[x] | 199 | val1[x] = '.' + val1[x] |
200 | for x in range(1, len(val2)): | 200 | for x in xrange(1, len(val2)): |
201 | if val2[x][0] == '0' : | 201 | if val2[x][0] == '0' : |
202 | val2[x] = '.' + val2[x] | 202 | val2[x] = '.' + val2[x] |
203 | 203 | ||
@@ -214,10 +214,10 @@ def vercmp_string(val1, val2): | |||
214 | val2[-1] += '_' + val2_prepart | 214 | val2[-1] += '_' + val2_prepart |
215 | # The above code will extend version numbers out so they | 215 | # The above code will extend version numbers out so they |
216 | # have the same number of digits. | 216 | # have the same number of digits. |
217 | for x in range(0, len(val1)): | 217 | for x in xrange(0, len(val1)): |
218 | cmp1 = relparse(val1[x]) | 218 | cmp1 = relparse(val1[x]) |
219 | cmp2 = relparse(val2[x]) | 219 | cmp2 = relparse(val2[x]) |
220 | for y in range(0, 3): | 220 | for y in xrange(0, 3): |
221 | myret = cmp1[y] - cmp2[y] | 221 | myret = cmp1[y] - cmp2[y] |
222 | if myret != 0: | 222 | if myret != 0: |
223 | __vercmp_cache__[valkey] = myret | 223 | __vercmp_cache__[valkey] = myret |
@@ -308,7 +308,7 @@ def _print_trace(body, line): | |||
308 | # print the environment of the method | 308 | # print the environment of the method |
309 | min_line = max(1, line-4) | 309 | min_line = max(1, line-4) |
310 | max_line = min(line + 4, len(body)) | 310 | max_line = min(line + 4, len(body)) |
311 | for i in range(min_line, max_line + 1): | 311 | for i in xrange(min_line, max_line + 1): |
312 | if line == i: | 312 | if line == i: |
313 | logger.error(" *** %.4d:%s" % (i, body[i-1]) ) | 313 | logger.error(" *** %.4d:%s" % (i, body[i-1]) ) |
314 | else: | 314 | else: |