1 |
Author: zmedico |
2 |
Date: 2008-03-28 09:32:04 +0000 (Fri, 28 Mar 2008) |
3 |
New Revision: 9534 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.2/pym/portage.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 |
(trunk r9363) |
13 |
|
14 |
|
15 |
Modified: main/branches/2.1.2/pym/portage.py |
16 |
=================================================================== |
17 |
--- main/branches/2.1.2/pym/portage.py 2008-03-28 09:30:19 UTC (rev 9533) |
18 |
+++ main/branches/2.1.2/pym/portage.py 2008-03-28 09:32:04 UTC (rev 9534) |
19 |
@@ -8037,6 +8037,7 @@ |
20 |
self._installed_instance = None |
21 |
self.contentscache = None |
22 |
self._contents_inodes = None |
23 |
+ self._contents_basenames = None |
24 |
|
25 |
def lockdb(self): |
26 |
if self._lock_vdb: |
27 |
@@ -8605,6 +8606,16 @@ |
28 |
if pkgfiles and destfile in pkgfiles: |
29 |
return True |
30 |
if pkgfiles: |
31 |
+ basename = os.path.basename(destfile) |
32 |
+ if self._contents_basenames is None: |
33 |
+ self._contents_basenames = set( |
34 |
+ os.path.basename(x) for x in pkgfiles) |
35 |
+ if basename not in self._contents_basenames: |
36 |
+ # This is a shortcut that, in most cases, allows us to |
37 |
+ # eliminate this package as an owner without the need |
38 |
+ # to examine inode numbers of parent directories. |
39 |
+ return False |
40 |
+ |
41 |
# Use stat rather than lstat since we want to follow |
42 |
# any symlinks to the real parent directory. |
43 |
parent_path = os.path.dirname(destfile) |
44 |
@@ -8640,7 +8651,6 @@ |
45 |
p_path_list = self._contents_inodes.get( |
46 |
(parent_stat.st_dev, parent_stat.st_ino)) |
47 |
if p_path_list: |
48 |
- basename = os.path.basename(destfile) |
49 |
for p_path in p_path_list: |
50 |
x = os.path.join(p_path, basename) |
51 |
if x in pkgfiles: |
52 |
@@ -9106,6 +9116,7 @@ |
53 |
for dblnk in others_in_slot: |
54 |
dblnk.contentscache = None |
55 |
dblnk._contents_inodes = None |
56 |
+ dblnk._contents_basenames = None |
57 |
|
58 |
# If portage is reinstalling itself, remove the old |
59 |
# version now since we want to use the temporary |
60 |
|
61 |
-- |
62 |
gentoo-commits@l.g.o mailing list |