From 3ed091443c53bff42ec1b8c9b5a1b8fa8b9a3e71 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 5 May 2008 21:07:53 +0000 Subject: [PATCH] Cache results for Task.__hash__() calls. (trunk r10210) svn path=/main/branches/2.1.2/; revision=10211 --- bin/emerge | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/emerge b/bin/emerge index 89e9a6430..4cc690f38 100755 --- a/bin/emerge +++ b/bin/emerge @@ -1361,7 +1361,7 @@ def show_masked_packages(masked_packages): return have_eapi_mask class Task(SlotObject): - __slots__ = ("_hash_key",) + __slots__ = ("_hash_key", "_hash_value") def _get_hash_key(self): hash_key = getattr(self, "_hash_key", None) @@ -1376,7 +1376,10 @@ class Task(SlotObject): return self._get_hash_key() != other def __hash__(self): - return hash(self._get_hash_key()) + hash_value = getattr(self, "_hash_value", None) + if hash_value is None: + self._hash_value = hash(self._get_hash_key()) + return self._hash_value def __len__(self): return len(self._get_hash_key()) -- 2.26.2