From 059e12ccd20f5c249724a8362d6bac325334ea76 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Wed, 28 Nov 2012 17:35:51 -0800 Subject: Use LruCache instead of GenerationCache in libhwui Change-Id: Ic26ddc7151eb5462bcd243b21daf7187ed6d3bec --- libs/hwui/PathCache.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'libs/hwui/PathCache.cpp') diff --git a/libs/hwui/PathCache.cpp b/libs/hwui/PathCache.cpp index 71a4ed7966ed..03ddf597b33a 100644 --- a/libs/hwui/PathCache.cpp +++ b/libs/hwui/PathCache.cpp @@ -55,22 +55,19 @@ PathCache::PathCache(): ShapeCache("path", } void PathCache::remove(SkPath* path) { - // TODO: Linear search... - Vector pathsToRemove; - for (size_t i = 0; i < mCache.size(); i++) { - if (mCache.getKeyAt(i).path == path) { - pathsToRemove.push(i); - removeTexture(mCache.getValueAt(i)); + Vector pathsToRemove; + LruCache::Iterator i(mCache); + + while (i.next()) { + const PathCacheEntry& key = i.key(); + if (key.path == path) { + pathsToRemove.push(key); } } - mCache.setOnEntryRemovedListener(NULL); for (size_t i = 0; i < pathsToRemove.size(); i++) { - // This will work because pathsToRemove is sorted - // and because the cache is a sorted keyed vector - mCache.removeAt(pathsToRemove.itemAt(i) - i); + mCache.remove(pathsToRemove.itemAt(i)); } - mCache.setOnEntryRemovedListener(this); } void PathCache::removeDeferred(SkPath* path) { -- cgit v1.2.3-59-g8ed1b