diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 3b1d9d6c5..05392127f 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -950,12 +950,13 @@ bool DivEngine::addSystem(DivSystem which) { unsigned int outs=disCont[i].dispatch->getOutputCount(); if (outs>16) outs=16; if (outs<2) { + song.patchbay.reserve(DIV_MAX_OUTPUTS); for (unsigned int j=0; j& where) { BUSY_BEGIN; where.clear(); + where.reserve(cmdStream.size()); for (DivCommand& i: cmdStream) { where.push_back(i); } @@ -2822,23 +2827,26 @@ void DivEngine::autoPatchbay() { unsigned int outs=disCont[i].dispatch->getOutputCount(); if (outs>16) outs=16; if (outs<2) { + song.patchbay.reserve(DIV_MAX_OUTPUTS); for (unsigned int j=0; j DivExportAmigaValidation::go(DivEngine* e) { } // finish + ret.reserve(5); ret.push_back(DivROMExportOutput("sbook.bin",sbook)); ret.push_back(DivROMExportOutput("wbook.bin",wbook)); ret.push_back(DivROMExportOutput("sample.bin",sample)); diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index 1465c816e..746f59046 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -342,6 +342,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { ds.insLen=16; } logI("reading instruments (%d)...",ds.insLen); + ds.ins.reserve(ds.insLen); for (int i=0; i0x0b) { ds.waveLen=(unsigned char)reader.readC(); logI("reading wavetables (%d)...",ds.waveLen); + ds.wave.reserve(ds.waveLen); for (int i=0; ilen=(unsigned char)reader.readI(); @@ -838,6 +840,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { // it appears this byte stored the YMU759 sample rate ymuSampleRate=reader.readC(); } + ds.sample.reserve(ds.sampleLen); for (int i=0; iordersLen); @@ -2345,6 +2349,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { // patchbay unsigned int conns=reader.readI(); + ds.patchbay.reserve(conns); for (unsigned int i=0; i=95) { + ds.subsong.reserve(numberOfSubSongs); for (int i=0; idepth=DIV_SAMPLE_DEPTH_8BIT; @@ -3373,6 +3384,7 @@ bool DivEngine::loadMod(unsigned char* file, size_t len) { } // instrument creation + ds.ins.reserve(insCount); for(int i=0; itype=DIV_INS_AMIGA; @@ -3651,6 +3663,7 @@ bool DivEngine::loadS3M(unsigned char* file, size_t len) { } // load instruments/samples + ds.ins.reserve(ds.insLen); for (int i=0; idepth=DIV_SAMPLE_DEPTH_8BIT; @@ -3981,6 +3999,7 @@ bool DivEngine::loadFC(unsigned char* file, size_t len) { return false; } logD("reading wavetables..."); + ds.wave.reserve(80); for (int i=0; i<80; i++) { DivWavetable* w=new DivWavetable; w->min=0; @@ -4009,6 +4028,7 @@ bool DivEngine::loadFC(unsigned char* file, size_t len) { } } else { // generate preset waves + ds.wave.reserve(48); for (int i=0; i<48; i++) { DivWavetable* w=new DivWavetable; generateFCPresetWave(i,w); @@ -4156,6 +4176,7 @@ bool DivEngine::loadFC(unsigned char* file, size_t len) { // volume sequence ins->std.volMacro.len=0; + ds.ins.reserve(64 - 5); for (int j=5; j<64; j++) { loopMap[j]=ins->std.volMacro.len; if (m.val[j]==0xe1) { // end @@ -4553,6 +4574,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len) { CHECK_BLOCK_VERSION(4); unsigned char totalSongs=reader.readC(); logV("%d songs:",totalSongs+1); + ds.subsong.reserve(totalSongs); for (int i=0; i<=totalSongs; i++) { String subSongName=reader.readString(); ds.subsong.push_back(new DivSubSong); @@ -5087,12 +5109,14 @@ DivDataErrors DivEngine::readAssetDirData(SafeReader& reader, std::vectorseek(0,SEEK_END); /// SUBSONGS + subSongPtr.reserve(song.subsong.size() - 1); for (subSongIndex=1; subSongIndextell()); @@ -5486,6 +5511,7 @@ SafeWriter* DivEngine::saveFur(bool notPrimary, bool newPatternFormat) { } /// CHIP FLAGS + sysFlagsPtr.reserve(song.systemLen); for (int i=0; itell()); @@ -5522,6 +5549,7 @@ SafeWriter* DivEngine::saveFur(bool notPrimary, bool newPatternFormat) { } /// WAVETABLE + wavePtr.reserve(song.waveLen); for (int i=0; itell()); @@ -5529,6 +5557,7 @@ SafeWriter* DivEngine::saveFur(bool notPrimary, bool newPatternFormat) { } /// SAMPLE + samplePtr.reserve(song.sampleLen); for (int i=0; itell()); @@ -5536,6 +5565,7 @@ SafeWriter* DivEngine::saveFur(bool notPrimary, bool newPatternFormat) { } /// PATTERN + patPtr.reserve(patsToWrite.size()); for (PatToWrite& i: patsToWrite) { DivPattern* pat=song.subsong[i.subsong]->pat[i.chan].getPattern(i.pat,false); patPtr.push_back(w->tell());