Improving compression performance (avoiding unnecessary file flush and better handling the 2GB limit)

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6109 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
wizou 2010-06-17 15:56:42 +00:00
parent 4d19aaa9ab
commit 9d452fc5d1
2 changed files with 6 additions and 5 deletions

View file

@ -794,9 +794,8 @@ int CEXEBuild::add_db_data(IMMap *mmap) // returns offset
{
// grow datablock so that there is room to compress into
int bufferlen = length + 1024 + length / 4; // give a nice 25% extra space
if (bufferlen < 0) // too much data... try allocating as much as possible
db->resize(max(st, 0x7fffffff));
else
if (st+bufferlen+sizeof(int) < 0) // we've hit a signed integer overflow (file is over 1.6 GB)
bufferlen = INT_MAX-st-sizeof(int); // so maximize compressor room and hope the file compresses well
db->resize(st + bufferlen + sizeof(int));
int n = compressor->Init(build_compress_level, build_compress_dict_size);
@ -2354,7 +2353,7 @@ int CEXEBuild::UpdatePEHeader()
void CEXEBuild::set_default_output_filename(const tstring& filename)
{
if (build_output_filename[0] == 0)
if (build_output_filename[0] == 0)
_tcsnccpy(build_output_filename,filename.c_str(),1024-1);
}

View file

@ -336,7 +336,7 @@ void MMapFile::flush(int num)
{
if (m_pView)
#ifdef _WIN32
FlushViewOfFile(m_pView, num);
{} // improving performance by commenting: FlushViewOfFile(m_pView, num);
#else
msync((char *)m_pView, num, MS_SYNC);
#endif
@ -431,6 +431,8 @@ void MMapBuf::resize(int newlen)
if (newlen > m_alloc)
{
m_alloc = newlen + (16 << 20); // add 16mb to top of mapping
if (m_alloc < 0) // we've hit a signed integer overflow
m_alloc = INT_MAX;
m_fm.resize(m_alloc);