[yum-cvs] yum/yum rpmsack.py,1.41,1.42

James Bowes jbowes at linux.duke.edu
Sat Apr 7 18:22:50 UTC 2007


Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv15510/yum

Modified Files:
	rpmsack.py 
Log Message:
Micro optimization: initialize the read-only transaction at object creation


Index: rpmsack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/rpmsack.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- rpmsack.py	2 Apr 2007 16:06:43 -0000	1.41
+++ rpmsack.py	7 Apr 2007 18:22:48 -0000	1.42
@@ -47,7 +47,7 @@
     def __init__(self, root='/'):
         self.root = root
         self._header_dict = {}
-        self.ts = None
+        self.ts = initReadOnlyTransaction(root=self.root)
         
     def _get_pkglist(self):
         '''Getter for the pkglist property. 
@@ -61,8 +61,6 @@
     pkglist = property(_get_pkglist, None)
 
     def readOnlyTS(self):
-        if not self.ts:
-            self.ts =  initReadOnlyTransaction(root=self.root)
         return self.ts
 
     def buildIndexes(self):
@@ -78,7 +76,7 @@
         pass
 
     def searchAll(self, name, query_type='like'):
-        ts = self.readOnlyTS()
+        ts = self.ts
         result = {}
 
         # check provides
@@ -100,7 +98,7 @@
 
     def searchFiles(self, name):
         """search the filelists in the rpms for anything matching name"""
-        ts = self.readOnlyTS()
+        ts = self.ts
         result = {}
         
         mi = ts.dbMatch('basenames', name)
@@ -115,7 +113,7 @@
         
     def searchPrco(self, name, prcotype):
         
-        ts = self.readOnlyTS()
+        ts = self.ts
         result = {}
         tag = self.DEP_TABLE[prcotype][0]
         mi = ts.dbMatch(tag, name)
@@ -210,7 +208,7 @@
     def _all_packages(self):
         '''Generator that yield (header, index) for all packages
         '''
-        ts = self.readOnlyTS()
+        ts = self.ts
         mi = ts.dbMatch()
 
         for hdr in mi:
@@ -223,7 +221,7 @@
         warnings.warn('_header_from_index() will go away in a future version of Yum.\n',
                 Errors.FutureDeprecationWarning, stacklevel=2)
 
-        ts = self.readOnlyTS()
+        ts = self.ts
         try:
             mi = ts.dbMatch(0, idx)
         except (TypeError, StopIteration), e:




More information about the Yum-cvs-commits mailing list