1 |
commit: 97d2dac2cb7ee7ad33a31786eed74e1c204576dd |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 24 20:14:59 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Sep 24 20:14:59 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=97d2dac2 |
7 |
|
8 |
portdbapi: tweak single-tree optimization |
9 |
|
10 |
This optimizes aux_get and cp_list for cases where we only have a |
11 |
single tree, which is common for repoman and ebuild(1). |
12 |
|
13 |
--- |
14 |
pym/portage/dbapi/porttree.py | 29 +++++++++++++++++++++-------- |
15 |
1 files changed, 21 insertions(+), 8 deletions(-) |
16 |
|
17 |
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py |
18 |
index d3cca00..42e5ca1 100644 |
19 |
--- a/pym/portage/dbapi/porttree.py |
20 |
+++ b/pym/portage/dbapi/porttree.py |
21 |
@@ -465,9 +465,16 @@ class portdbapi(dbapi): |
22 |
if mytree is None: |
23 |
raise KeyError(myrepo) |
24 |
|
25 |
- if not mytree: |
26 |
+ if mytree is not None and len(self.porttrees) == 1 \ |
27 |
+ and mytree == self.porttrees[0]: |
28 |
+ # mytree matches our only tree, so it's safe to |
29 |
+ # ignore mytree and cache the result |
30 |
+ mytree = None |
31 |
+ myrepo = None |
32 |
+ |
33 |
+ if mytree is None: |
34 |
cache_me = True |
35 |
- if not mytree and not self._known_keys.intersection( |
36 |
+ if mytree is None and not self._known_keys.intersection( |
37 |
mylist).difference(self._aux_cache_keys): |
38 |
aux_cache = self._aux_cache.get(mycpv) |
39 |
if aux_cache is not None: |
40 |
@@ -730,6 +737,14 @@ class portdbapi(dbapi): |
41 |
return l |
42 |
|
43 |
def cp_list(self, mycp, use_cache=1, mytree=None): |
44 |
+ |
45 |
+ if self.frozen and mytree is not None \ |
46 |
+ and len(self.porttrees) == 1 \ |
47 |
+ and mytree == self.porttrees[0]: |
48 |
+ # mytree matches our only tree, so it's safe to |
49 |
+ # ignore mytree and cache the result |
50 |
+ mytree = None |
51 |
+ |
52 |
if self.frozen and mytree is None: |
53 |
cachelist = self.xcache["cp-list"].get(mycp) |
54 |
if cachelist is not None: |
55 |
@@ -857,7 +872,7 @@ class portdbapi(dbapi): |
56 |
# match *all* visible *and* masked packages |
57 |
if mydep == mykey: |
58 |
myval = self.cp_list(mykey, mytree=mytree) |
59 |
- elif mydep.repo is not None or len(self.porttrees) == 1: |
60 |
+ elif mydep.repo is not None: |
61 |
myval = list(self._iter_match(mydep, |
62 |
self.cp_list(mykey, mytree=mytree))) |
63 |
else: |
64 |
@@ -886,7 +901,7 @@ class portdbapi(dbapi): |
65 |
if mydep == mykey: |
66 |
for myval in self.cp_list(mykey, mytree=mytree): |
67 |
break |
68 |
- elif mydep.repo is not None or len(self.porttrees) == 1: |
69 |
+ elif mydep.repo is not None: |
70 |
for myval in self._iter_match(mydep, |
71 |
self.cp_list(mykey, mytree=mytree)): |
72 |
break |
73 |
@@ -917,7 +932,7 @@ class portdbapi(dbapi): |
74 |
else: |
75 |
iterfunc = reversed |
76 |
|
77 |
- if mydep.repo is not None or len(self.porttrees) == 1: |
78 |
+ if mydep.repo is not None: |
79 |
repos = [mydep.repo] |
80 |
else: |
81 |
# We iterate over self.porttrees, since it's common to |
82 |
@@ -1010,9 +1025,7 @@ class portdbapi(dbapi): |
83 |
aux_keys = list(self._aux_cache_keys) |
84 |
metadata = {} |
85 |
|
86 |
- if len(self.porttrees) == 1: |
87 |
- repos = [None] |
88 |
- elif myrepo is not None: |
89 |
+ if myrepo is not None: |
90 |
repos = [myrepo] |
91 |
else: |
92 |
# We iterate over self.porttrees, since it's common to |