From 8b5d9d33abbb93226f46398e1d46b49514645c69 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 4 Dec 2017 14:45:36 -0800 Subject: [PATCH] Fix LruCache when next_score overflows --- src/lru_cache.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lru_cache.h b/src/lru_cache.h index 477deb4e..6b3de44e 100644 --- a/src/lru_cache.h +++ b/src/lru_cache.h @@ -114,9 +114,9 @@ void LruCache::IncrementScore() { // Overflow. if (next_score_ == 0) { std::sort(entries_.begin(), entries_.end(), [](const Entry& a, const Entry& b) { - return a.score > b.score; + return a.score < b.score; }); for (Entry& entry : entries_) entry.score = next_score_++; } -} \ No newline at end of file +}