Use a stack variable for hash computation in GrBinHashKey
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 12 Dec 2011 22:35:18 +0000 (22:35 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 12 Dec 2011 22:35:18 +0000 (22:35 +0000)
Review URL: http://codereview.appspot.com/5484054/

git-svn-id: http://skia.googlecode.com/svn/trunk@2863 2bbb7eff-a529-9590-31e7-b0007b416f81

src/gpu/GrBinHashKey.h

index ceaef7a..028bb91 100644 (file)
@@ -39,24 +39,25 @@ public:
     ~GrBinHashKey() {
     }
 
-    void setKeyData(const uint32_t *data) {
+    void setKeyData(const uint32_t* SK_RESTRICT data) {
         GrAssert(GrIsALIGN4(KeySize));
         memcpy(&fData, data, KeySize);
 
-        fHash = 0;
+        uint32_t hash = 0;
         size_t len = KeySize;
         while (len >= 4) {
-            fHash += *data++;
-            fHash += (fHash << 10);
-            fHash ^= (fHash >> 6);
+            hash += *data++;
+            hash += (fHash << 10);
+            hash ^= (hash >> 6);
             len -= 4;
         }
-        fHash += (fHash << 3);
-        fHash ^= (fHash >> 11);
-        fHash += (fHash << 15);
+        hash += (fHash << 3);
+        hash ^= (fHash >> 11);
+        hash += (fHash << 15);
 #if GR_DEBUG
         fIsValid = true;
 #endif
+        fHash = hash;
     }
 
     int compare(const GrBinHashKey<Entry, KeySize>& key) const {