Chromium Code Reviews| Index: src/gpu/GrProgramDesc.h |
| diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h |
| index b306f02e4f78a27e8292b7345bef4f1d7b434915..891688c808d95a512e51372aba0a9e30f04b529d 100644 |
| --- a/src/gpu/GrProgramDesc.h |
| +++ b/src/gpu/GrProgramDesc.h |
| @@ -39,9 +39,17 @@ public: |
| return *this; |
| } |
| - bool operator== (const GrProgramDesc& other) const { |
| - // The length is masked as a hint to the compiler that the address will be 4 byte aligned. |
| - return 0 == memcmp(this->asKey(), other.asKey(), this->keyLength() & ~0x3); |
| + bool operator== (const GrProgramDesc& that) const { |
|
robertphillips
2015/06/04 22:15:50
'.'?
bsalomon
2015/06/04 22:16:33
Done.
|
| + SkASSERT(SkIsAlign4(this->.keyLength())); |
| + int l = this->keyLength() >> 2; |
| + const uint32_t* aKey = this->asKey(); |
| + const uint32_t* bKey = that.asKey(); |
| + for (int i = 0; i < l; ++i) { |
| + if (aKey[i] != bKey[i]) { |
| + return false; |
| + } |
| + } |
| + return true; |
| } |
| bool operator!= (const GrProgramDesc& other) const { |
| @@ -49,7 +57,16 @@ public: |
| } |
| static bool Less(const GrProgramDesc& a, const GrProgramDesc& b) { |
| - return memcmp(a.asKey(), b.asKey(), a.keyLength() & ~0x3) < 0; |
| + SkASSERT(SkIsAlign4(a.keyLength())); |
| + int l = a.keyLength() >> 2; |
| + const uint32_t* aKey = a.asKey(); |
| + const uint32_t* bKey = b.asKey(); |
| + for (int i = 0; i < l; ++i) { |
| + if (aKey[i] != bKey[i]) { |
| + return aKey[i] < bKey[i] ? true : false; |
| + } |
| + } |
| + return false; |
| } |
| struct KeyHeader { |