Skip to content
Snippets Groups Projects
Commit a8d314d1 authored by Oliver Bock's avatar Oliver Bock
Browse files

Optimized code (pre-determine resource size, pre-allocate vector)

parent 519b3671
Branches
No related tags found
No related merge requests found
...@@ -9,10 +9,12 @@ ResourceFactory::ResourceFactory() ...@@ -9,10 +9,12 @@ ResourceFactory::ResourceFactory()
for(int i = 0; i < resourceCount; ++i) { for(int i = 0; i < resourceCount; ++i) {
// prepare temporary buffer // prepare temporary buffer
size_t resourceSize = c_ResourceIndex[i+1][1];
vector<unsigned char> buffer; vector<unsigned char> buffer;
buffer.reserve(resourceSize);
// extract resource data from storage container // extract resource data from storage container
for(size_t x = 0; x < c_ResourceIndex[i+1][1]; ++x) { for(size_t x = 0; x < resourceSize; ++x) {
// use offset and relative position to find the absolute position // use offset and relative position to find the absolute position
unsigned char byteValue = c_ResourceStorage[c_ResourceIndex[i+1][0] + x]; unsigned char byteValue = c_ResourceStorage[c_ResourceIndex[i+1][0] + x];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment