Skip to content
Snippets Groups Projects
Commit a9ddf49e authored by Adrien Béraud's avatar Adrien Béraud
Browse files

storage: check size before returning oldest

parent de3dba7c
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,7 @@ public:
insert(id, value, expiration);
}
size_t size() const { return totalSize_; }
std::pair<InfoHash, Value::Id> getOldest() const { return storedValues_.begin()->second; }
std::pair<InfoHash, Value::Id> getOldest() const { return storedValues_.empty() ? std::pair<InfoHash, Value::Id>{} : storedValues_.begin()->second; }
private:
std::multimap<time_point, std::pair<InfoHash, Value::Id>> storedValues_;
size_t totalSize_ {0};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment