From: Richard Purdie Date: Fri, 3 Jun 2016 12:35:32 +0000 (+0100) Subject: codeparser: Small optimisation to stop repeated hash() calls X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=633c0c19f87a92497a7e9771811cdc953e1b7047;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git codeparser: Small optimisation to stop repeated hash() calls No functionality change, just avoids function call overhead in a function which loops heavily. Signed-off-by: Richard Purdie --- diff --git a/lib/bb/codeparser.py b/lib/bb/codeparser.py index b1d067a2f1b..6ed2adeed9d 100644 --- a/lib/bb/codeparser.py +++ b/lib/bb/codeparser.py @@ -65,9 +65,10 @@ class SetCache(object): for i in items: new.append(sys.intern(i)) s = frozenset(new) - if hash(s) in self.setcache: - return self.setcache[hash(s)] - self.setcache[hash(s)] = s + h = hash(s) + if h in self.setcache: + return self.setcache[h] + self.setcache[h] = s return s codecache = SetCache()