From bf34127d818fb7da8bb82921496c23f1746889f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 16 Mar 2012 15:40:31 +0000 Subject: [PATCH] Speed up call hashing. --- scripts/unpickle.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/unpickle.py b/scripts/unpickle.py index fd7989b..98e2c30 100755 --- a/scripts/unpickle.py +++ b/scripts/unpickle.py @@ -43,6 +43,7 @@ class Call: def __init__(self, callTuple): self.no, self.functionName, self.args, self.ret = callTuple + self._hash = None def __str__(self): s = self.functionName @@ -61,10 +62,11 @@ class Call: self.ret == other.ret def __hash__(self): - # XXX: hack due to unhashable types - #return hash(self.functionName) ^ hash(tuple(self.args)) ^ hash(self.ret) - return hash(self.functionName) ^ hash(repr(self.args)) ^ hash(repr(self.ret)) - + if self._hash is None: + # XXX: hack due to unhashable types + #self._hash = hash(self.functionName) ^ hash(tuple(self.args)) ^ hash(self.ret) + self._hash = hash(self.functionName) ^ hash(repr(self.args)) ^ hash(repr(self.ret)) + return self._hash class Unpickler: -- 2.45.2