mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-29 00:06:41 +00:00
Call push_back() if inserting to the end of the vector. It seems MSVC may be generating different code compared to insert().
This commit is contained in:
parent
77394fce99
commit
257126ed69
1 changed files with 12 additions and 7 deletions
|
@ -443,20 +443,25 @@ namespace CSMWorld
|
|||
void Collection<ESXRecordT, IdAccessorT>::insertRecord (const RecordBase& record, int index,
|
||||
UniversalId::Type type)
|
||||
{
|
||||
if (index<0 || index>static_cast<int> (mRecords.size()))
|
||||
int size = static_cast<int>(mRecords.size());
|
||||
if (index < 0 || index > size)
|
||||
throw std::runtime_error ("index out of range");
|
||||
|
||||
const Record<ESXRecordT>& record2 = dynamic_cast<const Record<ESXRecordT>&> (record);
|
||||
|
||||
if (index == size)
|
||||
mRecords.push_back (record2);
|
||||
else
|
||||
mRecords.insert (mRecords.begin()+index, record2);
|
||||
|
||||
if (index<static_cast<int> (mRecords.size())-1)
|
||||
if (index < size-1)
|
||||
{
|
||||
for (std::map<std::string, int>::iterator iter (mIndex.begin()); iter!=mIndex.end();
|
||||
++iter)
|
||||
if (iter->second>=index)
|
||||
for (std::map<std::string, int>::iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter)
|
||||
{
|
||||
if (iter->second >= index)
|
||||
++(iter->second);
|
||||
}
|
||||
}
|
||||
|
||||
mIndex.insert (std::make_pair (Misc::StringUtils::lowerCase (IdAccessorT().getId (
|
||||
record2.get())), index));
|
||||
|
|
Loading…
Reference in a new issue