diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-10 21:03:23 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-10 21:03:23 +0000 |
commit | c967795b8f63bda26b76694e08a642136e22cb5b (patch) | |
tree | efa6337d2b7ec7da6dafee3615e1f41c4337da18 | |
parent | 99a5ac0b67a14048a1db3f429878775854d29397 (diff) |
Make it possible to share a comparison func with both SkTSearch and SkQSort
Review URL: http://codereview.appspot.com/6006043/
git-svn-id: http://skia.googlecode.com/svn/trunk@3648 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/core/SkPtrRecorder.h | 2 | ||||
-rw-r--r-- | include/core/SkTSearch.h | 6 | ||||
-rw-r--r-- | src/core/SkPtrRecorder.cpp | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/include/core/SkPtrRecorder.h b/include/core/SkPtrRecorder.h index 11fd17043e..2df84b245a 100644 --- a/include/core/SkPtrRecorder.h +++ b/include/core/SkPtrRecorder.h @@ -71,7 +71,7 @@ private: // is not related to its "index". SkTDArray<Pair> fList; - static int Cmp(const Pair& a, const Pair& b); + static int Cmp(const Pair* a, const Pair* b); typedef SkRefCnt INHERITED; }; diff --git a/include/core/SkTSearch.h b/include/core/SkTSearch.h index d5ab18ceda..abe727fe03 100644 --- a/include/core/SkTSearch.h +++ b/include/core/SkTSearch.h @@ -47,7 +47,7 @@ int SkTSearch(const T* base, int count, const T& target, size_t elemSize) template <typename T> int SkTSearch(const T* base, int count, const T& target, size_t elemSize, - int (*compare)(const T&, const T&)) + int (*compare)(const T*, const T*)) { SkASSERT(count >= 0); if (count <= 0) { @@ -63,14 +63,14 @@ int SkTSearch(const T* base, int count, const T& target, size_t elemSize, int mid = (hi + lo) >> 1; const T* elem = (const T*)((const char*)base + mid * elemSize); - if ((*compare)(*elem, target) < 0) + if ((*compare)(elem, &target) < 0) lo = mid + 1; else hi = mid; } const T* elem = (const T*)((const char*)base + hi * elemSize); - int pred = (*compare)(*elem, target); + int pred = (*compare)(elem, &target); if (pred != 0) { if (pred < 0) hi += 1; diff --git a/src/core/SkPtrRecorder.cpp b/src/core/SkPtrRecorder.cpp index e3a9eee3bb..e509464a4d 100644 --- a/src/core/SkPtrRecorder.cpp +++ b/src/core/SkPtrRecorder.cpp @@ -18,8 +18,8 @@ void SkPtrSet::reset() { fList.reset(); } -int SkPtrSet::Cmp(const Pair& a, const Pair& b) { - return (char*)a.fPtr - (char*)b.fPtr; +int SkPtrSet::Cmp(const Pair* a, const Pair* b) { + return (char*)a->fPtr - (char*)b->fPtr; } uint32_t SkPtrSet::find(void* ptr) const { |