Implement dblink.__hash__ and __eq__, so that `portageq owners` correctly groups
authorZac Medico <zmedico@gentoo.org>
Mon, 16 Nov 2009 00:31:08 +0000 (00:31 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 16 Nov 2009 00:31:08 +0000 (00:31 -0000)
search results. Also, increase iter_owners dblink cache size from 25 to 100
instances. (trunk r14817)

svn path=/main/branches/2.1.7/; revision=14835

pym/portage/dbapi/vartree.py

index cb9c57216706b950a46a881748b4ffa6c295acd1..a6b69e9ff768d874e1ccb09593d0f1cc77f1e9f6 100644 (file)
@@ -908,7 +908,7 @@ class vardbapi(dbapi):
                        def dblink(cpv):
                                x = dblink_cache.get(cpv)
                                if x is None:
-                                       if len(dblink_fifo) >= 25:
+                                       if len(dblink_fifo) >= 100:
                                                # Ensure that we don't run out of memory.
                                                del dblink_cache[dblink_fifo.popleft().mycpv]
                                        x = self._vardb._dblink(cpv)
@@ -1201,6 +1201,14 @@ class dblink(object):
                self._contents_inodes = None
                self._contents_basenames = None
                self._md5_merge_map = {}
+               self._hash_key = (self.myroot, self.mycpv)
+
+       def __hash__(self):
+               return hash(self._hash_key)
+
+       def __eq__(self, other):
+               return isinstance(other, dblink) and \
+                       self._hash_key == other._hash_key
 
        def lockdb(self):
                if self._lock_vdb: