diff --git a/src/unordered_lru_cache.h b/src/unordered_lru_cache.h index 8a364b8547..7208737dde 100644 --- a/src/unordered_lru_cache.h +++ b/src/unordered_lru_cache.h @@ -36,7 +36,6 @@ public: template void _emplace(const Key& key, Value2&& v) { - truncate_if_needed(); auto it = cacheMap.find(key); if (it == cacheMap.end()) { cacheMap.emplace(key, std::make_pair(std::forward(v), accessCounter++)); @@ -44,6 +43,7 @@ public: it->second.first = std::forward(v); it->second.second = accessCounter++; } + truncate_if_needed(); } void emplace(const Key& key, Value&& v)