Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r15296 - main/trunk/pym/portage/cache
Date: Sun, 31 Jan 2010 00:53:50
Message-Id: E1NbO4S-00051W-48@stork.gentoo.org
1 Author: zmedico
2 Date: 2010-01-31 00:53:47 +0000 (Sun, 31 Jan 2010)
3 New Revision: 15296
4
5 Modified:
6 main/trunk/pym/portage/cache/flat_hash.py
7 Log:
8 Make __iter__ use list.pop() instead of pop(0), for greater efficiency.
9
10
11 Modified: main/trunk/pym/portage/cache/flat_hash.py
12 ===================================================================
13 --- main/trunk/pym/portage/cache/flat_hash.py 2010-01-31 00:43:59 UTC (rev 15295)
14 +++ main/trunk/pym/portage/cache/flat_hash.py 2010-01-31 00:53:47 UTC (rev 15296)
15 @@ -122,20 +122,19 @@
16 """generator for walking the dir struct"""
17 dirs = [(0, self.location)]
18 len_base = len(self.location)
19 - while len(dirs):
20 + while dirs:
21 + depth, dir_path = dirs.pop()
22 try:
23 - depth = dirs[0][0]
24 - dir_list = os.listdir(dirs[0][1])
25 + dir_list = os.listdir(dir_path)
26 except OSError as e:
27 if e.errno != errno.ENOENT:
28 raise
29 del e
30 - dirs.pop(0)
31 continue
32 for l in dir_list:
33 if l.endswith(".cpickle"):
34 continue
35 - p = os.path.join(dirs[0][1], l)
36 + p = os.path.join(dir_path, l)
37 st = os.lstat(p)
38 if stat.S_ISDIR(st.st_mode):
39 # Only recurse 1 deep, in order to avoid iteration over
40 @@ -146,4 +145,3 @@
41 dirs.append((depth+1, p))
42 continue
43 yield p[len_base+1:]
44 - dirs.pop(0)