Search for Strike at head of LRU first

Switch to checking the head of the linked list for the LRU before searching
the hash table.

Change-Id: If28f4759ef609dde11778db8ba91cc9dfdd6a259
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274399
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Herb Derby 2020-03-01 17:36:17 -06:00 committed by Skia Commit-Bot
parent 8121d27b29
commit 73ae40a424

View File

@ -124,6 +124,11 @@ sk_sp<SkStrike> SkStrikeCache::findStrike(const SkDescriptor& desc) {
}
auto SkStrikeCache::internalFindStrikeOrNull(const SkDescriptor& desc) -> sk_sp<Strike> {
// Check head because it is likely the strike we are looking for.
if (fHead != nullptr && fHead->getDescriptor() == desc) { return sk_ref_sp(fHead); }
// Do the heavy search looking for the strike.
sk_sp<Strike>* strikeHandle = fStrikeLookup.find(desc);
if (strikeHandle == nullptr) { return nullptr; }
Strike* strikePtr = strikeHandle->get();