Treat generation 0 a bit specially.

I guess we could always check gen 0 first, that'd be readahead/backfill.
This commit is contained in:
Unknown W. Brackets 2014-11-24 14:10:48 -08:00
parent 27eb38df8d
commit df5020c439

View File

@ -538,11 +538,12 @@ bool CachingFileLoader::MakeCacheSpaceFor(size_t blocks, bool readingAhead) {
for (auto it = blocks_.begin(); it != blocks_.end(); ) {
// Check for the minimum seen generation.
// TODO: Do this smarter?
if (it->second.generation < minGeneration) {
if (it->second.generation != 0 && it->second.generation < minGeneration) {
minGeneration = it->second.generation;
}
if (it->second.generation == oldestGeneration_) {
// 0 means it was never used yet or was the first read (e.g. block descriptor.)
if (it->second.generation == oldestGeneration_ || it->second.generation == 0) {
s64 pos = it->first;
delete it->second.ptr;
blocks_.erase(it);