mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
improve cleanup
This commit is contained in:
@@ -44,12 +44,18 @@ public:
|
||||
bump_to_front(key);
|
||||
return it->second;
|
||||
}
|
||||
|
||||
if (data_.size() >= capacity_)
|
||||
{
|
||||
Key const& lru = usage_list_.back();
|
||||
usage_list_.pop_back();
|
||||
data_.erase(lru);
|
||||
std::size_t excess = (data_.size() + 1) - capacity_;
|
||||
for (std::size_t i = 0; i < excess; ++i)
|
||||
{
|
||||
Key const& lru = usage_list_.back();
|
||||
usage_list_.pop_back();
|
||||
data_.erase(lru);
|
||||
}
|
||||
}
|
||||
|
||||
usage_list_.push_front(key);
|
||||
return data_[key];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user