Speed up texture cache init. (Was exceptionally slow with a debugger attached)

This commit is contained in:
Shyotl
2018-04-29 01:58:04 -05:00
parent 798f4c1a69
commit 07835ea832
3 changed files with 12 additions and 13 deletions

View File

@@ -29,6 +29,7 @@
#include "linden_common.h"
#include "llapr.h"
#include "llscopedvolatileaprpool.h"
#include <limits>
bool ll_apr_warn_status(apr_status_t status)
{
@@ -150,7 +151,7 @@ apr_status_t LLAPRFile::open(const std::string& filename, apr_int32_t flags, BOO
return open(filename, flags, use_global_pool ? LLAPRFile::long_lived : LLAPRFile::short_lived);
}
// File I/O
S32 LLAPRFile::read(void *buf, S32 nbytes)
S32 LLAPRFile::read(void *buf, U64 nbytes)
{
if(!mFile)
{
@@ -167,12 +168,12 @@ S32 LLAPRFile::read(void *buf, S32 nbytes)
}
else
{
llassert_always(sz <= 0x7fffffff);
llassert_always(sz <= std::numeric_limits<apr_size_t>::max());
return (S32)sz;
}
}
S32 LLAPRFile::write(const void *buf, S32 nbytes)
S32 LLAPRFile::write(const void *buf, U64 nbytes)
{
if(!mFile)
{
@@ -189,7 +190,7 @@ S32 LLAPRFile::write(const void *buf, S32 nbytes)
}
else
{
llassert_always(sz <= 0x7fffffff);
llassert_always(sz <= std::numeric_limits<apr_size_t>::max());
return (S32)sz;
}
}

View File

@@ -92,8 +92,8 @@ public:
apr_status_t eof() { return apr_file_eof(mFile);}
// Returns bytes read/written, 0 if read/write fails:
S32 read(void* buf, S32 nbytes);
S32 write(const void* buf, S32 nbytes);
S32 read(void* buf, U64 nbytes);
S32 write(const void* buf, U64 nbytes);
apr_file_t* getFileHandle() {return mFile;}

View File

@@ -1305,14 +1305,12 @@ void LLTextureCache::writeEntriesAndClose(const std::vector<Entry>& entries)
if (!mReadOnly)
{
LLAPRFile* aprfile = openHeaderEntriesFile(false, (S32)sizeof(EntriesInfo));
for (S32 idx=0; idx<num_entries; idx++)
U64 write_size = U64(sizeof(Entry)) * num_entries;
U64 bytes_written = aprfile->write((void*)(entries.data()), write_size);
if (bytes_written != write_size)
{
S32 bytes_written = aprfile->write((void*)(&entries[idx]), (S32)sizeof(Entry));
if(bytes_written != sizeof(Entry))
{
clearCorruptedCache(); //clear the cache.
return;
}
clearCorruptedCache(); //clear the cache.
return;
}
closeHeaderEntriesFile();
}