summaryrefslogtreecommitdiffstats
path: root/libs/hwui/ProgramCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/ProgramCache.cpp')
-rw-r--r--libs/hwui/ProgramCache.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 62835e0..3bbd520 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -417,11 +417,6 @@ ProgramCache::~ProgramCache() {
void ProgramCache::clear() {
PROGRAM_LOGD("Clearing program cache");
-
- size_t count = mCache.size();
- for (size_t i = 0; i < count; i++) {
- delete mCache.valueAt(i);
- }
mCache.clear();
}
@@ -433,14 +428,14 @@ Program* ProgramCache::get(const ProgramDescription& description) {
key = PROGRAM_KEY_TEXTURE;
}
- ssize_t index = mCache.indexOfKey(key);
- Program* program = NULL;
- if (index < 0) {
+ auto iter = mCache.find(key);
+ Program* program = nullptr;
+ if (iter == mCache.end()) {
description.log("Could not find program");
program = generateProgram(description, key);
- mCache.add(key, program);
+ mCache[key] = std::unique_ptr<Program>(program);
} else {
- program = mCache.valueAt(index);
+ program = iter->second.get();
}
return program;
}