1 |
Author: zmedico |
2 |
Date: 2008-02-21 08:04:33 +0000 (Thu, 21 Feb 2008) |
3 |
New Revision: 9363 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/dbapi/vartree.py |
7 |
Log: |
8 |
Optimize dblink.isowner() to use fewer stat calls by doing a basename |
9 |
comparison to try and eliminate the file before resorting to inode |
10 |
comparison. This speeds up the `portageq owners` command as well as |
11 |
the search that is done when collision-protect finds a collision. |
12 |
|
13 |
|
14 |
Modified: main/trunk/pym/portage/dbapi/vartree.py |
15 |
=================================================================== |
16 |
--- main/trunk/pym/portage/dbapi/vartree.py 2008-02-20 20:52:22 UTC (rev 9362) |
17 |
+++ main/trunk/pym/portage/dbapi/vartree.py 2008-02-21 08:04:33 UTC (rev 9363) |
18 |
@@ -911,6 +911,7 @@ |
19 |
self._installed_instance = None |
20 |
self.contentscache = None |
21 |
self._contents_inodes = None |
22 |
+ self._contents_basenames = None |
23 |
|
24 |
def lockdb(self): |
25 |
if self._lock_vdb: |
26 |
@@ -1512,6 +1513,16 @@ |
27 |
if pkgfiles and destfile in pkgfiles: |
28 |
return True |
29 |
if pkgfiles: |
30 |
+ basename = os.path.basename(destfile) |
31 |
+ if self._contents_basenames is None: |
32 |
+ self._contents_basenames = set( |
33 |
+ os.path.basename(x) for x in pkgfiles) |
34 |
+ if basename not in self._contents_basenames: |
35 |
+ # This is a shortcut that, in most cases, allows us to |
36 |
+ # eliminate this package as an owner without the need |
37 |
+ # to examine inode numbers of parent directories. |
38 |
+ return False |
39 |
+ |
40 |
# Use stat rather than lstat since we want to follow |
41 |
# any symlinks to the real parent directory. |
42 |
parent_path = os.path.dirname(destfile) |
43 |
@@ -1547,7 +1558,6 @@ |
44 |
p_path_list = self._contents_inodes.get( |
45 |
(parent_stat.st_dev, parent_stat.st_ino)) |
46 |
if p_path_list: |
47 |
- basename = os.path.basename(destfile) |
48 |
for p_path in p_path_list: |
49 |
x = os.path.join(p_path, basename) |
50 |
if x in pkgfiles: |
51 |
@@ -2103,6 +2113,7 @@ |
52 |
for dblnk in others_in_slot: |
53 |
dblnk.contentscache = None |
54 |
dblnk._contents_inodes = None |
55 |
+ dblnk._contents_basenames = None |
56 |
|
57 |
# If portage is reinstalling itself, remove the old |
58 |
# version now since we want to use the temporary |
59 |
|
60 |
-- |
61 |
gentoo-commits@l.g.o mailing list |