From 8e0189a2af9e5e746070c9401be04381a91a3760 Mon Sep 17 00:00:00 2001 From: Marat Radchenko Date: Fri, 20 May 2011 08:25:17 +0400 Subject: Package: precalculate _hash_key This eliminates an expensive getattr call in _get_hash_key(), which greatly improves depgraph performance on a weak ARM cpu. --- pym/_emerge/Package.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'pym') 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): -- cgit v1.2.3-1-g7c22