diff options
Diffstat (limited to 'indra/newview/llvocache.cpp')
-rw-r--r-- | indra/newview/llvocache.cpp | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 8bdb8e069e..145ee31260 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -28,6 +28,7 @@ #include "llvocache.h" #include "llerror.h" #include "llregionhandle.h" +#include "llviewercontrol.h" BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { @@ -223,7 +224,6 @@ BOOL LLVOCacheEntry::writeToFile(LLAPRFile* apr_file) const // Format string used to construct filename for the object cache static const char OBJECT_CACHE_FILENAME[] = "objects_%d_%d.slc"; -const U32 MAX_NUM_OBJECT_ENTRIES = 128 ; const U32 NUM_ENTRIES_TO_PURGE = 16 ; const char* object_cache_dirname = "objectcache"; const char* header_filename = "object.cache"; @@ -232,11 +232,11 @@ LLVOCache* LLVOCache::sInstance = NULL; //static LLVOCache* LLVOCache::getInstance() -{ +{ if(!sInstance) { sInstance = new LLVOCache() ; -} + } return sInstance ; } @@ -262,13 +262,17 @@ LLVOCache::LLVOCache(): mNumEntries(0), mCacheSize(1) { + mEnabled = gSavedSettings.getBOOL("ObjectCacheEnabled"); mLocalAPRFilePoolp = new LLVolatileAPRPool() ; } LLVOCache::~LLVOCache() { - writeCacheHeader(); - clearCacheInMemory(); + if(mEnabled) + { + writeCacheHeader(); + clearCacheInMemory(); + } delete mLocalAPRFilePoolp; } @@ -282,7 +286,7 @@ void LLVOCache::setDirNames(ELLPath location) void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) { - if(mInitialized) + if(mInitialized || !mEnabled) { return ; } @@ -291,9 +295,9 @@ void LLVOCache::initCache(ELLPath location, U32 size, U32 cache_version) if (!mReadOnly) { LLFile::mkdir(mObjectCacheDirName); - } - mCacheSize = llclamp(size, - MAX_NUM_OBJECT_ENTRIES, NUM_ENTRIES_TO_PURGE); + } + + mCacheSize = size; mMetaInfo.mVersion = cache_version; readCacheHeader(); @@ -409,6 +413,11 @@ BOOL LLVOCache::checkWrite(LLAPRFile* apr_file, void* src, S32 n_bytes) void LLVOCache::readCacheHeader() { + if(!mEnabled) + { + return ; + } + //clear stale info. clearCacheInMemory(); @@ -424,7 +433,7 @@ void LLVOCache::readCacheHeader() HeaderEntryInfo* entry ; mNumEntries = 0 ; - while(mNumEntries < MAX_NUM_OBJECT_ENTRIES) + while(mNumEntries < mCacheSize) { entry = new HeaderEntryInfo() ; if(!checkRead(apr_file, entry, sizeof(HeaderEntryInfo))) @@ -453,7 +462,7 @@ void LLVOCache::readCacheHeader() void LLVOCache::writeCacheHeader() { - if(mReadOnly) + if(mReadOnly || !mEnabled) { return ; } @@ -477,10 +486,10 @@ void LLVOCache::writeCacheHeader() } mNumEntries = mHeaderEntryQueue.size() ; - if(mNumEntries < MAX_NUM_OBJECT_ENTRIES) + if(mNumEntries < mCacheSize) { HeaderEntryInfo* entry = new HeaderEntryInfo() ; - for(S32 i = mNumEntries ; i < MAX_NUM_OBJECT_ENTRIES ; i++) + for(U32 i = mNumEntries ; i < mCacheSize; i++) { //fill the cache with the default entry. if(!checkWrite(apr_file, entry, sizeof(HeaderEntryInfo))) @@ -504,6 +513,10 @@ BOOL LLVOCache::updateEntry(const HeaderEntryInfo* entry) void LLVOCache::readFromCache(U64 handle, const LLUUID& id, LLVOCacheEntry::vocache_entry_map_t& cache_entry_map) { + if(!mEnabled) + { + return ; + } llassert_always(mInitialized); handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ; @@ -573,6 +586,10 @@ void LLVOCache::purgeEntries() void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) { + if(!mEnabled) + { + return ; + } llassert_always(mInitialized); if(mReadOnly) |