summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/CompressedBlob.cpp
diff options
context:
space:
mode:
authorUnknown W. Brackets <checkins@unknownbrackets.org>2014-11-27 08:34:44 -0800
committerUnknown W. Brackets <checkins@unknownbrackets.org>2014-11-27 08:34:44 -0800
commit2635e7d9eaf6f96463de0a75a0b5a07c274b2cb4 (patch)
tree10f3b518cdcbd7b930ba9642db5ba48d100a0fbb /Source/Core/DiscIO/CompressedBlob.cpp
parentf2f83a0c608f51fe4533624bddade0886e1febe7 (diff)
DiscIO: Decompress to file using a larger buffer.
This improves performance by around 20% for me, and the memory use impact is negligible considering Dolphin is otherwise unusable.
Diffstat (limited to 'Source/Core/DiscIO/CompressedBlob.cpp')
-rw-r--r--Source/Core/DiscIO/CompressedBlob.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/Source/Core/DiscIO/CompressedBlob.cpp b/Source/Core/DiscIO/CompressedBlob.cpp
index 660d5c8c98..6170c5ad07 100644
--- a/Source/Core/DiscIO/CompressedBlob.cpp
+++ b/Source/Core/DiscIO/CompressedBlob.cpp
@@ -311,20 +311,23 @@ bool DecompressBlobToFile(const std::string& infile, const std::string& outfile,
}
const CompressedBlobHeader &header = reader->GetHeader();
- u8* buffer = new u8[header.block_size];
- int progress_monitor = std::max<int>(1, header.num_blocks / 100);
+ static const size_t BUFFER_BLOCKS = 32;
+ size_t buffer_size = header.block_size * BUFFER_BLOCKS;
+ u8* buffer = new u8[buffer_size];
+ u32 num_buffers = header.num_blocks / BUFFER_BLOCKS;
+ int progress_monitor = std::max<int>(1, num_buffers / 100);
bool was_cancelled = false;
- for (u64 i = 0; i < header.num_blocks; i++)
+ for (u64 i = 0; i < num_buffers; i++)
{
if (i % progress_monitor == 0)
{
- was_cancelled = !callback("Unpacking", (float)i / (float)header.num_blocks, arg);
+ was_cancelled = !callback("Unpacking", (float)i / (float)num_buffers, arg);
if (was_cancelled)
break;
}
- reader->Read(i * header.block_size, header.block_size, buffer);
- f.WriteBytes(buffer, header.block_size);
+ reader->Read(i * buffer_size, buffer_size, buffer);
+ f.WriteBytes(buffer, buffer_size);
}
delete[] buffer;