mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-30 12:32:36 +00:00
Call push_back() if inserting to the end of the vector. It seems MSVC may be generating different code compared to insert().
(copied the changes from commit SHA-1: 257126ed69a5f6f964ba771766de061e81f87433)
This commit is contained in:
parent
44a333b6db
commit
725d689e8a
@ -543,21 +543,26 @@ namespace CSMWorld
|
|||||||
void Collection<ESXRecordT, IdAccessorT>::insertRecord (std::unique_ptr<RecordBase> record, int index,
|
void Collection<ESXRecordT, IdAccessorT>::insertRecord (std::unique_ptr<RecordBase> record, int index,
|
||||||
UniversalId::Type type)
|
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");
|
throw std::runtime_error ("index out of range");
|
||||||
|
|
||||||
std::unique_ptr<Record<ESXRecordT> > record2(static_cast<Record<ESXRecordT>*>(record.release()));
|
std::unique_ptr<Record<ESXRecordT> > record2(static_cast<Record<ESXRecordT>*>(record.release()));
|
||||||
std::string lowerId = Misc::StringUtils::lowerCase(IdAccessorT().getId(record2->get()));
|
std::string lowerId = Misc::StringUtils::lowerCase(IdAccessorT().getId(record2->get()));
|
||||||
|
|
||||||
|
if (index == size)
|
||||||
|
mRecords.push_back (std::move(record2));
|
||||||
|
else
|
||||||
mRecords.insert (mRecords.begin()+index, std::move(record2));
|
mRecords.insert (mRecords.begin()+index, std::move(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();
|
for (std::map<std::string, int>::iterator iter (mIndex.begin()); iter!=mIndex.end(); ++iter)
|
||||||
++iter)
|
{
|
||||||
if (iter->second>=index)
|
if (iter->second >= index)
|
||||||
++(iter->second);
|
++(iter->second);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mIndex.insert (std::make_pair (lowerId, index));
|
mIndex.insert (std::make_pair (lowerId, index));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user