[yum-cvs] yum/yum rpmsack.py,1.38,1.39
Jeremy Katz
katzj at linux.duke.edu
Fri Mar 30 15:32:17 UTC 2007
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv27221/yum
Modified Files:
rpmsack.py
Log Message:
some speedups
* don't use yield with _get_pkglist; we've already generated the list and
just returning it is faster
* remove inner match() function of _search() so that we don't have
the overhead of a bazillion function calls. yes, this is noticable.
Index: rpmsack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/rpmsack.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- rpmsack.py 27 Feb 2007 22:18:02 -0000 1.38
+++ rpmsack.py 30 Mar 2007 15:32:15 -0000 1.39
@@ -56,8 +56,7 @@
if len(self._header_dict.keys()) == 0 :
self._make_header_dict()
- for pkgtup in self._header_dict.keys():
- yield pkgtup
+ return self._header_dict.keys()
pkglist = property(_get_pkglist, None)
@@ -257,40 +256,20 @@
if val != None:
lookfor.append((i, val))
- def match(tup):
- for idx, val in lookfor:
- if tup[idx] != val:
- return False
- return True
-
# Find and yield matches
if not self._header_dict:
self._make_header_dict()
-
- for pkgtup in self._header_dict.keys():
- if match(pkgtup):
- (hdr, idx) = self._header_dict[pkgtup]
- yield hdr, pkgtup, idx
-
- def _search2(self, name=None, epoch=None, version=None, release=None, arch=None):
- '''Generator that yield (header, index) for matching packages
-
- This version uses RPM to do the work but it's significantly slower than _search()
- Not actually used.
- '''
- ts = self.readOnlyTS()
- mi = ts.dbMatch()
- # Set up the search patterns
- for arg in ('name', 'epoch', 'version', 'release', 'arch'):
- val = locals()[arg]
- if val != None:
- mi.pattern(arg, rpm.RPMMIRE_DEFAULT, val)
-
- # Report matches
- for hdr in mi:
- if hdr['name'] != 'gpg-pubkey':
- yield (hdr, mi.instance())
+ ret = []
+ for (pkgtup, (hdr, idx)) in self._header_dict.items():
+ ok = True
+ for idx, val in lookfor:
+ if pkgtup[idx] != val:
+ ok = False
+ break
+ if ok:
+ ret.append( (hdr, pkgtup, idx) )
+ return ret
def _makePackageObject(self, hdr, index):
@@ -429,7 +408,7 @@
returns a list of pkgtuples of providing packages, possibly empty"""
pkgs = self.searchRequires(name)
-
+
if flags == 0:
flags = None
if type(version) is types.StringType:
More information about the Yum-cvs-commits
mailing list