Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: src/gpu/GrProgramDesc.h

Issue 1154773007: Remove memcmp from GrProgramDesc op== and Less (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix assert Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrProgramDesc.h
diff --git a/src/gpu/GrProgramDesc.h b/src/gpu/GrProgramDesc.h
index b306f02e4f78a27e8292b7345bef4f1d7b434915..05b52cc7cd7dfaa948854487e90101ea382fd58d 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 {
+ 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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698