aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-01-31 00:53:47 +0000
committerZac Medico <zmedico@gentoo.org>2010-01-31 00:53:47 +0000
commitd0c0df648967f1d8e9e52e70b3055eb6d670da29 (patch)
tree9b8ecec73f5836727fe548cbbade3ad1cbeb653a /pym/portage/cache
parentBug #302764 - Inside __iter__, only recurse 1 deep, in order to avoid (diff)
downloadportage-d0c0df648967f1d8e9e52e70b3055eb6d670da29.tar.gz
portage-d0c0df648967f1d8e9e52e70b3055eb6d670da29.tar.bz2
portage-d0c0df648967f1d8e9e52e70b3055eb6d670da29.zip
Make __iter__ use list.pop() instead of pop(0), for greater efficiency.
svn path=/main/trunk/; revision=15296
Diffstat (limited to 'pym/portage/cache')
-rw-r--r--pym/portage/cache/flat_hash.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/pym/portage/cache/flat_hash.py b/pym/portage/cache/flat_hash.py
index f882c2475..a010e5061 100644
--- a/pym/portage/cache/flat_hash.py
+++ b/pym/portage/cache/flat_hash.py
@@ -122,20 +122,19 @@ class database(fs_template.FsBased):
"""generator for walking the dir struct"""
dirs = [(0, self.location)]
len_base = len(self.location)
- while len(dirs):
+ while dirs:
+ depth, dir_path = dirs.pop()
try:
- depth = dirs[0][0]
- dir_list = os.listdir(dirs[0][1])
+ dir_list = os.listdir(dir_path)
except OSError as e:
if e.errno != errno.ENOENT:
raise
del e
- dirs.pop(0)
continue
for l in dir_list:
if l.endswith(".cpickle"):
continue
- p = os.path.join(dirs[0][1], l)
+ p = os.path.join(dir_path, l)
st = os.lstat(p)
if stat.S_ISDIR(st.st_mode):
# Only recurse 1 deep, in order to avoid iteration over
@@ -146,4 +145,3 @@ class database(fs_template.FsBased):
dirs.append((depth+1, p))
continue
yield p[len_base+1:]
- dirs.pop(0)