--- libgig/trunk/src/gig.cpp 2021/06/17 10:09:42 3935 +++ libgig/trunk/src/gig.cpp 2021/06/17 10:29:54 3936 @@ -609,8 +609,8 @@ uint16_t iSampleGroup = 0; // 0 refers to default sample group File* pFile = static_cast(pParent); if (pFile->pGroups) { - std::list::iterator iter = pFile->pGroups->begin(); - std::list::iterator end = pFile->pGroups->end(); + std::vector::iterator iter = pFile->pGroups->begin(); + std::vector::iterator end = pFile->pGroups->end(); for (int i = 0; iter != end; i++, iter++) { if (*iter == pGroup) { iSampleGroup = i; @@ -6286,8 +6286,8 @@ File::~File() { if (pGroups) { - std::list::iterator iter = pGroups->begin(); - std::list::iterator end = pGroups->end(); + std::vector::iterator iter = pGroups->begin(); + std::vector::iterator end = pGroups->end(); while (iter != end) { delete *iter; ++iter; @@ -6958,12 +6958,8 @@ */ Group* File::GetGroup(size_t index) { if (!pGroups) LoadGroups(); - GroupsIterator = pGroups->begin(); - for (size_t i = 0; GroupsIterator != pGroups->end(); i++) { - if (i == index) return *GroupsIterator; - ++GroupsIterator; - } - return NULL; + if (index >= pGroups->size()) return NULL; + return (*pGroups)[index]; } /** @@ -7004,7 +7000,8 @@ */ void File::DeleteGroup(Group* pGroup) { if (!pGroups) LoadGroups(); - std::list::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup); + std::vector::iterator iter = + find(pGroups->begin(), pGroups->end(), pGroup); if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); // delete all members of this group @@ -7030,7 +7027,8 @@ */ void File::DeleteGroupOnly(Group* pGroup) { if (!pGroups) LoadGroups(); - std::list::iterator iter = find(pGroups->begin(), pGroups->end(), pGroup); + std::vector::iterator iter = + find(pGroups->begin(), pGroups->end(), pGroup); if (iter == pGroups->end()) throw gig::Exception("Could not delete group, could not find given group"); if (pGroups->size() == 1) throw gig::Exception("Cannot delete group, there must be at least one default group!"); // move all members of this group to another group @@ -7041,7 +7039,7 @@ } void File::LoadGroups() { - if (!pGroups) pGroups = new std::list; + if (!pGroups) pGroups = new std::vector; // try to read defined groups from file RIFF::List* lst3gri = pRIFF->GetSubList(LIST_TYPE_3GRI); if (lst3gri) { @@ -7240,8 +7238,8 @@ } } - std::list::iterator iter = pGroups->begin(); - std::list::iterator end = pGroups->end(); + std::vector::iterator iter = pGroups->begin(); + std::vector::iterator end = pGroups->end(); for (; iter != end; ++iter) { (*iter)->UpdateChunks(pProgress); }