Fix LruCache when next_score overflows

This commit is contained in:
Fangrui Song 2017-12-04 14:45:36 -08:00 committed by Jacob Dufault
parent 4a7194d2df
commit 8b5d9d33ab

View File

@ -114,7 +114,7 @@ void LruCache<TKey, TValue>::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_++;