diff options
author | Oz Linden <oz@lindenlab.com> | 2011-03-16 21:22:45 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2011-03-16 21:22:45 -0400 |
commit | 31edad0a226a14b5b87fe364c629f8450bda567c (patch) | |
tree | e03ed820a759cd5d5c5f4f930762f73b0fe4cf24 /indra/newview/lltexturecache.cpp | |
parent | b6e6ba224620e0b122062c88f40295c10ce8db2d (diff) | |
parent | 742dd75751f65224d80eb4f7d20daf5a21776c5f (diff) |
merge changes for storm-357
Diffstat (limited to 'indra/newview/lltexturecache.cpp')
-rw-r--r-- | indra/newview/lltexturecache.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/indra/newview/lltexturecache.cpp b/indra/newview/lltexturecache.cpp index f54214b95c..7fb52c1939 100644 --- a/indra/newview/lltexturecache.cpp +++ b/indra/newview/lltexturecache.cpp @@ -1419,22 +1419,21 @@ void LLTextureCache::readHeaderCache() } } } - if (num_entries > sCacheMaxEntries) + if (num_entries - empty_entries > sCacheMaxEntries) { // Special case: cache size was reduced, need to remove entries // Note: After we prune entries, we will call this again and create the LRU - U32 entries_to_purge = (num_entries-empty_entries) - sCacheMaxEntries; + U32 entries_to_purge = (num_entries - empty_entries) - sCacheMaxEntries; llinfos << "Texture Cache Entries: " << num_entries << " Max: " << sCacheMaxEntries << " Empty: " << empty_entries << " Purging: " << entries_to_purge << llendl; - if (entries_to_purge > 0) + // We can exit the following loop with the given condition, since if we'd reach the end of the lru set we'd have: + // purge_list.size() = lru.size() = num_entries - empty_entries = entries_to_purge + sCacheMaxEntries >= entries_to_purge + // So, it's certain that iter will never reach lru.end() first. + std::set<lru_data_t>::iterator iter = lru.begin(); + while (purge_list.size() < entries_to_purge) { - for (std::set<lru_data_t>::iterator iter = lru.begin(); iter != lru.end(); ++iter) - { - purge_list.insert(iter->second); - if (purge_list.size() >= entries_to_purge) - break; - } + purge_list.insert(iter->second); + ++iter; } - llassert_always(purge_list.size() >= entries_to_purge); } else { |