Call push_back() if inserting to the end of the vector. It seems MSVC may be generating different code compared to insert().

pull/1955/head
cc9cii 9 years ago
parent 77394fce99
commit 257126ed69

@ -443,19 +443,24 @@ 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);
mRecords.insert (mRecords.begin()+index, record2);
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)
++(iter->second);
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 (

Loading…
Cancel
Save