diff options
author | robertphillips <robertphillips@google.com> | 2016-05-24 14:17:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-24 14:17:13 -0700 |
commit | c4ed68426649dd4ca2c3119cdafdd562d3c3ba28 (patch) | |
tree | 6dad7ad2d21aa5eaeffa79b45ad58d0a07ac9c6e /src/core/SkTMultiMap.h | |
parent | 7a5bcc5f59bdf122217bc8ca7e756e8c76bae9e1 (diff) |
Don't store resources with a unique key in GrResourceCache's fScratchMap
The reasoning here is that resources with a unique key are never selected from fScratchMap and just clog up the search for an available resource.
This knocks a 200x loop over the SVGbouncingrects case from 264ms down to 164ms.
BUG=603969
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2008083002
Review-Url: https://codereview.chromium.org/2008083002
Diffstat (limited to 'src/core/SkTMultiMap.h')
-rw-r--r-- | src/core/SkTMultiMap.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/core/SkTMultiMap.h b/src/core/SkTMultiMap.h index 4c8683cb8c..dc521debc9 100644 --- a/src/core/SkTMultiMap.h +++ b/src/core/SkTMultiMap.h @@ -102,6 +102,51 @@ public: int count() const { return fCount; } #ifdef SK_DEBUG + class ConstIter { + public: + explicit ConstIter(const SkTMultiMap* mmap) + : fIter(&(mmap->fHash)) + , fList(nullptr) { + if (!fIter.done()) { + fList = &(*fIter); + } + } + + bool done() const { + return fIter.done(); + } + + const T* operator*() { + SkASSERT(fList); + return fList->fValue; + } + + void operator++() { + if (fList) { + fList = fList->fNext; + } + if (!fList) { + ++fIter; + if (!fIter.done()) { + fList = &(*fIter); + } + } + } + + private: + typename SkTDynamicHash<ValueList, Key>::ConstIter fIter; + const ValueList* fList; + }; + + bool has(const T* value, const Key& key) const { + for (ValueList* list = fHash.find(key); list; list = list->fNext) { + if (list->fValue == value) { + return true; + } + } + return false; + } + // This is not particularly fast and only used for validation, so debug only. int countForKey(const Key& key) const { int count = 0; |