From 4d631744b079df80d601139588f0eb15840c8880 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sun, 10 Mar 2024 18:54:13 -0500 Subject: [PATCH] policy_cache.hpp --- src/policy_cache.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/policy_cache.hpp b/src/policy_cache.hpp index 95a0ee29..b6a68203 100644 --- a/src/policy_cache.hpp +++ b/src/policy_cache.hpp @@ -41,10 +41,13 @@ public: insert(std::string const &key_, std::string const &val_) { + auto size = _cache.size(); + _cache.visit_while([&](Map::value_type const &v_) { _cache.erase(v_.first); - return (_cache.size() > _max_size); + --size; + return (size > _max_size); }); _cache.insert_or_assign(key_,val_);