Skip to contentSkip to conversation

codeparser: Small optimisation to stop repeated hash() calls

PATCH New Richard Purdie 1 participant 1 message Jun 3, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 codeparser: Small optimisation to stop repeated hash() calls

No functionality change, just avoids function call overhead in a function which loops heavily.

bitbake/lib/bb/codeparser.py +4 -3
index 00551ba..25938d6 100644
@@ -69,9 +69,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()