Use a stack variable for hash computation in GrBinHashKey
Review URL: http://codereview.appspot.com/5484054/
git-svn-id: http://skia.googlecode.com/svn/trunk@2863 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrBinHashKey.h b/src/gpu/GrBinHashKey.h
index ceaef7a..028bb91 100644
--- a/src/gpu/GrBinHashKey.h
+++ b/src/gpu/GrBinHashKey.h
@@ -39,24 +39,25 @@
~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 {