From: José Fonseca Date: Fri, 16 Mar 2012 15:40:31 +0000 (+0000) Subject: Speed up call hashing. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=bf34127d818fb7da8bb82921496c23f1746889f3;p=apitrace Speed up call hashing. --- 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: