--- libgig/trunk/src/gig.cpp 2021/06/18 15:46:44 3945 +++ libgig/trunk/src/gig.cpp 2021/06/19 10:38:45 3955 @@ -4801,8 +4801,8 @@ ScriptGroup::~ScriptGroup() { if (pScripts) { - std::list::iterator iter = pScripts->begin(); - std::list::iterator end = pScripts->end(); + std::vector::iterator iter = pScripts->begin(); + std::vector::iterator end = pScripts->end(); while (iter != end) { delete *iter; ++iter; @@ -4840,7 +4840,7 @@ // now store the name of this group as chunk as subchunk of the list chunk ::SaveString(CHUNK_ID_LSNM, NULL, pList, Name, String("Unnamed Group"), true, 64); - for (std::list::iterator it = pScripts->begin(); + for (std::vector::iterator it = pScripts->begin(); it != pScripts->end(); ++it) { (*it)->UpdateChunks(pProgress); @@ -4855,12 +4855,10 @@ * @param index - number of the sought script (0..n) * @returns sought script or NULL if there's no such script */ - Script* ScriptGroup::GetScript(uint index) { + Script* ScriptGroup::GetScript(size_t index) { if (!pScripts) LoadScripts(); - std::list::iterator it = pScripts->begin(); - for (uint i = 0; it != pScripts->end(); ++i, ++it) - if (i == index) return *it; - return NULL; + if (index >= pScripts->size()) return NULL; + return (*pScripts)[index]; } /** @brief Add new instrument script. @@ -4893,7 +4891,7 @@ */ void ScriptGroup::DeleteScript(Script* pScript) { if (!pScripts) LoadScripts(); - std::list::iterator iter = + std::vector::iterator iter = find(pScripts->begin(), pScripts->end(), pScript); if (iter == pScripts->end()) throw gig::Exception("Could not delete script, could not find given script"); @@ -4906,7 +4904,7 @@ void ScriptGroup::LoadScripts() { if (pScripts) return; - pScripts = new std::list; + pScripts = new std::vector; if (!pList) return; size_t i = 0; @@ -5503,7 +5501,7 @@ File* pFile = (File*) GetParent(); for (uint k = 0; k < scriptPoolFileOffsets.size(); ++k) { uint32_t soughtOffset = scriptPoolFileOffsets[k].fileOffset; - for (uint i = 0; pFile->GetScriptGroup(i); ++i) { + for (size_t i = 0; pFile->GetScriptGroup(i); ++i) { ScriptGroup* group = pFile->GetScriptGroup(i); for (uint s = 0; group->GetScript(s); ++s) { Script* script = group->GetScript(s); @@ -5541,7 +5539,7 @@ * @param index - instrument script slot index * @returns script or NULL if index is out of bounds */ - Script* Instrument::GetScriptOfSlot(uint index) { + Script* Instrument::GetScriptOfSlot(size_t index) { LoadScripts(); if (index >= pScriptRefs->size()) return NULL; return pScriptRefs->at(index).script; @@ -5602,7 +5600,7 @@ * @param index1 - index of the first script slot to swap * @param index2 - index of the second script slot to swap */ - void Instrument::SwapScriptSlots(uint index1, uint index2) { + void Instrument::SwapScriptSlots(size_t index1, size_t index2) { LoadScripts(); if (index1 >= pScriptRefs->size() || index2 >= pScriptRefs->size()) return; @@ -5617,7 +5615,7 @@ * * @param index - index of script slot to remove */ - void Instrument::RemoveScriptSlot(uint index) { + void Instrument::RemoveScriptSlot(size_t index) { LoadScripts(); if (index >= pScriptRefs->size()) return; pScriptRefs->erase( pScriptRefs->begin() + index ); @@ -5658,8 +5656,8 @@ * GigaStudio 4 software. It will currently only work with LinuxSampler and * gigedit. */ - uint Instrument::ScriptSlotCount() const { - return uint(pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size()); + size_t Instrument::ScriptSlotCount() const { + return pScriptRefs ? pScriptRefs->size() : scriptPoolFileOffsets.size(); } /** @brief Whether script execution shall be skipped. @@ -5718,8 +5716,8 @@ * the @c Script identified by passed @p uuid. */ bool Instrument::ReferencesScriptWithUuid(const _UUID& uuid) { - const uint nSlots = ScriptSlotCount(); - for (uint iSlot = 0; iSlot < nSlots; ++iSlot) + const size_t nSlots = ScriptSlotCount(); + for (size_t iSlot = 0; iSlot < nSlots; ++iSlot) if (_UUIDFromCArray(&GetScriptOfSlot(iSlot)->Uuid[0]) == uuid) return true; return false; @@ -6305,8 +6303,8 @@ delete pGroups; } if (pScriptGroups) { - std::list::iterator iter = pScriptGroups->begin(); - std::list::iterator end = pScriptGroups->end(); + std::vector::iterator iter = pScriptGroups->begin(); + std::vector::iterator end = pScriptGroups->end(); while (iter != end) { delete *iter; ++iter; @@ -6412,7 +6410,6 @@ pSample->DeleteChunks(); delete pSample; - SampleList::iterator tmp = SamplesIterator; // remove all references to the sample size_t iIns = 0; for (Instrument* instrument = GetInstrument(iIns); instrument; @@ -6430,7 +6427,6 @@ } } } - SamplesIterator = tmp; // restore iterator } void File::LoadSamples() { @@ -6715,7 +6711,7 @@ } // clone script groups and their scripts - for (int iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) { + for (size_t iGroup = 0; pFile->GetScriptGroup(iGroup); ++iGroup) { ScriptGroup* sg = pFile->GetScriptGroup(iGroup); ScriptGroup* dg = AddScriptGroup(); dg->Name = "COPY" + ToString(iCallCount) + "_" + sg->Name; @@ -7107,12 +7103,10 @@ * @param index - number of the sought group (0..n) * @returns sought script group or NULL if there's no such group */ - ScriptGroup* File::GetScriptGroup(uint index) { + ScriptGroup* File::GetScriptGroup(size_t index) { if (!pScriptGroups) LoadScriptGroups(); - std::list::iterator it = pScriptGroups->begin(); - for (uint i = 0; it != pScriptGroups->end(); ++i, ++it) - if (i == index) return *it; - return NULL; + if (index >= pScriptGroups->size()) return NULL; + return (*pScriptGroups)[index]; } /** @brief Get instrument script group (by name). @@ -7125,9 +7119,10 @@ */ ScriptGroup* File::GetScriptGroup(const String& name) { if (!pScriptGroups) LoadScriptGroups(); - std::list::iterator it = pScriptGroups->begin(); - for (uint i = 0; it != pScriptGroups->end(); ++i, ++it) - if ((*it)->Name == name) return *it; + for (size_t i = 0; i < pScriptGroups->size(); ++i) { + ScriptGroup* pGroup = (*pScriptGroups)[i]; + if (pGroup->Name == name) return pGroup; + } return NULL; } @@ -7160,7 +7155,7 @@ */ void File::DeleteScriptGroup(ScriptGroup* pScriptGroup) { if (!pScriptGroups) LoadScriptGroups(); - std::list::iterator iter = + std::vector::iterator iter = find(pScriptGroups->begin(), pScriptGroups->end(), pScriptGroup); if (iter == pScriptGroups->end()) throw gig::Exception("Could not delete script group, could not find given script group"); @@ -7175,7 +7170,7 @@ void File::LoadScriptGroups() { if (pScriptGroups) return; - pScriptGroups = new std::list; + pScriptGroups = new std::vector; RIFF::List* lstLS = pRIFF->GetSubList(LIST_TYPE_3LS); if (lstLS) { size_t i = 0; @@ -7220,7 +7215,7 @@ // of the respective instrument script chunk as reference. if (pScriptGroups) { // Update instrument script (group) chunks. - for (std::list::iterator it = pScriptGroups->begin(); + for (std::vector::iterator it = pScriptGroups->begin(); it != pScriptGroups->end(); ++it) { (*it)->UpdateChunks(pProgress);