| 148 | } |
| 149 | |
| 150 | std::shared_ptr<Resource> ResourceCache::findScratchResource(const ScratchKey& scratchKey) { |
| 151 | auto result = scratchKeyMap.find(scratchKey); |
| 152 | if (result == scratchKeyMap.end()) { |
| 153 | return nullptr; |
| 154 | } |
| 155 | auto& list = result->second; |
| 156 | size_t index = 0; |
| 157 | bool found = false; |
| 158 | for (auto& resource : list) { |
| 159 | if (resource->isPurgeable() && !resource->hasExternalReferences()) { |
| 160 | found = true; |
| 161 | break; |
| 162 | } |
| 163 | index++; |
| 164 | } |
| 165 | if (!found) { |
| 166 | return nullptr; |
| 167 | } |
| 168 | auto resource = list[index]; |
| 169 | return refResource(resource); |
| 170 | } |
| 171 | |
| 172 | std::shared_ptr<Resource> ResourceCache::findUniqueResource(const UniqueKey& uniqueKey) { |
| 173 | auto resource = getUniqueResource(uniqueKey); |
no test coverage detected