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:
parent
4d19aaa9ab
commit
9d452fc5d1
2 changed files with 6 additions and 5 deletions
|
@ -794,9 +794,8 @@ int CEXEBuild::add_db_data(IMMap *mmap) // returns offset
|
||||||
{
|
{
|
||||||
// grow datablock so that there is room to compress into
|
// grow datablock so that there is room to compress into
|
||||||
int bufferlen = length + 1024 + length / 4; // give a nice 25% extra space
|
int bufferlen = length + 1024 + length / 4; // give a nice 25% extra space
|
||||||
if (bufferlen < 0) // too much data... try allocating as much as possible
|
if (st+bufferlen+sizeof(int) < 0) // we've hit a signed integer overflow (file is over 1.6 GB)
|
||||||
db->resize(max(st, 0x7fffffff));
|
bufferlen = INT_MAX-st-sizeof(int); // so maximize compressor room and hope the file compresses well
|
||||||
else
|
|
||||||
db->resize(st + bufferlen + sizeof(int));
|
db->resize(st + bufferlen + sizeof(int));
|
||||||
|
|
||||||
int n = compressor->Init(build_compress_level, build_compress_dict_size);
|
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)
|
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);
|
_tcsnccpy(build_output_filename,filename.c_str(),1024-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,7 @@ void MMapFile::flush(int num)
|
||||||
{
|
{
|
||||||
if (m_pView)
|
if (m_pView)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FlushViewOfFile(m_pView, num);
|
{} // improving performance by commenting: FlushViewOfFile(m_pView, num);
|
||||||
#else
|
#else
|
||||||
msync((char *)m_pView, num, MS_SYNC);
|
msync((char *)m_pView, num, MS_SYNC);
|
||||||
#endif
|
#endif
|
||||||
|
@ -431,6 +431,8 @@ void MMapBuf::resize(int newlen)
|
||||||
if (newlen > m_alloc)
|
if (newlen > m_alloc)
|
||||||
{
|
{
|
||||||
m_alloc = newlen + (16 << 20); // add 16mb to top of mapping
|
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);
|
m_fm.resize(m_alloc);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue