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

Side by Side Diff: tests/HashCacheTest.cpp

Issue 88113002: Speed up GrResourceCache lookup by inlining GrBinHashKey comparisons (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments (capitalized statics) Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/GrUnitTests.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 8
9 #include "Test.h" 9 #include "Test.h"
10 10
(...skipping 21 matching lines...) Expand all
32 return elem->fValue < 0; 32 return elem->fValue < 0;
33 } 33 }
34 }; 34 };
35 35
36 class HashKey { 36 class HashKey {
37 public: 37 public:
38 HashKey(int key) : fKey(key) {} 38 HashKey(int key) : fKey(key) {}
39 39
40 uint32_t getHash() const { return fKey; } 40 uint32_t getHash() const { return fKey; }
41 41
42 static bool LT(const HashElement& entry, const HashKey& key) { 42 static bool LessThan(const HashElement& entry, const HashKey& key) {
43 return entry.fKey < key.fKey; 43 return entry.fKey < key.fKey;
44 } 44 }
45 static bool EQ(const HashElement& entry, const HashKey& key) { 45 static bool Equals(const HashElement& entry, const HashKey& key) {
46 return entry.fKey == key.fKey; 46 return entry.fKey == key.fKey;
47 } 47 }
48 48
49 #ifdef SK_DEBUG 49 #ifdef SK_DEBUG
50 static uint32_t GetHash(const HashElement& entry) { 50 static bool LessThan(const HashElement& a, const HashElement& b) {
51 return entry.fKey;
52 }
53 static bool LT(const HashElement& a, const HashElement& b) {
54 return a.fKey < b.fKey; 51 return a.fKey < b.fKey;
55 } 52 }
56 static bool EQ(const HashElement& a, const HashElement& b) { 53 static bool Equals(const HashElement& a, const HashElement& b) {
57 return a.fKey == b.fKey; 54 return a.fKey == b.fKey;
58 } 55 }
59 #endif 56 #endif
60 57
61 protected: 58 protected:
62 int fKey; 59 int fKey;
63 }; 60 };
64 61
65 //////////////////////////////////////////////////////////////////////////////// 62 ////////////////////////////////////////////////////////////////////////////////
66 static void TestHashCache(skiatest::Reporter* reporter) { 63 static void TestHashCache(skiatest::Reporter* reporter) {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 HashElement* found = cache.find(0); 152 HashElement* found = cache.find(0);
156 REPORTER_ASSERT(reporter, NULL == found); 153 REPORTER_ASSERT(reporter, NULL == found);
157 } 154 }
158 } 155 }
159 156
160 //////////////////////////////////////////////////////////////////////////////// 157 ////////////////////////////////////////////////////////////////////////////////
161 #include "TestClassDef.h" 158 #include "TestClassDef.h"
162 DEFINE_TESTCLASS("HashCache", HashCacheTestClass, TestHashCache) 159 DEFINE_TESTCLASS("HashCache", HashCacheTestClass, TestHashCache)
163 160
164 #endif 161 #endif
OLDNEW
« no previous file with comments | « tests/GrUnitTests.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698