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: ...@@ -62,7 +62,7 @@ public:
insert(id, value, expiration); insert(id, value, expiration);
} }
size_t size() const { return totalSize_; } 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: private:
std::multimap<time_point, std::pair<InfoHash, Value::Id>> storedValues_; std::multimap<time_point, std::pair<InfoHash, Value::Id>> storedValues_;
size_t totalSize_ {0}; size_t totalSize_ {0};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment