summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarat Radchenko <marat@slonopotamus.org>2011-05-20 08:25:17 +0400
committerZac Medico <zmedico@gentoo.org>2011-05-19 21:52:28 -0700
commit8e0189a2af9e5e746070c9401be04381a91a3760 (patch)
tree680f9a26d6c47b3d8897925068ce9a016efc6aba
parent36cd3c2b0a932b59ef91b50ad3bc7ba1a2072d75 (diff)
downloadportage-8e0189a2af9e5e746070c9401be04381a91a3760.tar.gz
portage-8e0189a2af9e5e746070c9401be04381a91a3760.tar.bz2
portage-8e0189a2af9e5e746070c9401be04381a91a3760.zip
Package: precalculate _hash_key
This eliminates an expensive getattr call in _get_hash_key(), which greatly improves depgraph performance on a weak ARM cpu.
-rw-r--r--pym/_emerge/Package.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py
index 2dfcc8502..12fa537aa 100644
--- a/pym/_emerge/Package.py
+++ b/pym/_emerge/Package.py
@@ -81,6 +81,15 @@ class Package(Task):
else:
self.operation = "merge"
+ # For installed (and binary) packages we don't care for the repo
+ # when it comes to hashing, because there can only be one cpv.
+ # So overwrite the repo_key with type_name.
+ repo_key = self.metadata.get('repository')
+ if self.type_name != 'ebuild':
+ repo_key = self.type_name
+ self._hash_key = \
+ (self.type_name, self.root, self.cpv, self.operation, repo_key)
+
def _validate_deps(self):
"""
Validate deps. This does not trigger USE calculation since that
@@ -266,7 +275,6 @@ class Package(Task):
self.cpv, self.metadata)
return pmask is not None
-
def _metadata_exception(self, k, e):
# For unicode safety with python-2.x we need to avoid
@@ -453,16 +461,6 @@ class Package(Task):
return missing_iuse
def _get_hash_key(self):
- hash_key = getattr(self, "_hash_key", None)
- if hash_key is None:
- # For installed (and binary) packages we don't care for the repo
- # when it comes to hashing, because there can only be one cpv.
- # So overwrite the repo_key with type_name.
- repo_key = self.metadata.get('repository')
- if self.type_name != 'ebuild':
- repo_key = self.type_name
- self._hash_key = \
- (self.type_name, self.root, self.cpv, self.operation, repo_key)
return self._hash_key
def __len__(self):