]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
codeparser: Small optimisation to stop repeated hash() calls
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 3 Jun 2016 12:35:32 +0000 (13:35 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 3 Jun 2016 12:47:15 +0000 (13:47 +0100)
No functionality change, just avoids function call overhead in a
function which loops heavily.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/codeparser.py

index b1d067a2f1bfa7413088462b9983a2d76980e5c7..6ed2adeed9d1c30190fa2162d2d98a46085682f0 100644 (file)
@@ -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()