mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +00:00
Use insert_or_assign() instead of hand rolled version.
This commit is contained in:
parent
3944648f0b
commit
fb344d27e0
1 changed files with 6 additions and 19 deletions
|
@ -58,10 +58,7 @@ namespace MWWorld
|
|||
|
||||
record.load(esm, isDeleted);
|
||||
|
||||
// Try to overwrite existing record
|
||||
std::pair<typename Static::iterator, bool> ret = mStatic.insert(std::make_pair(record.mIndex, record));
|
||||
if (!ret.second)
|
||||
ret.first->second = record;
|
||||
mStatic.insert_or_assign(record.mIndex, record);
|
||||
}
|
||||
template<typename T>
|
||||
int IndexedStore<T>::getSize() const
|
||||
|
@ -181,11 +178,9 @@ namespace MWWorld
|
|||
record.load(esm, isDeleted);
|
||||
Misc::StringUtils::lowerCaseInPlace(record.mId);
|
||||
|
||||
std::pair<typename Static::iterator, bool> inserted = mStatic.insert(std::make_pair(record.mId, record));
|
||||
std::pair<typename Static::iterator, bool> inserted = mStatic.insert_or_assign(record.mId, record);
|
||||
if (inserted.second)
|
||||
mShared.push_back(&inserted.first->second);
|
||||
else
|
||||
inserted.first->second = record;
|
||||
|
||||
return RecordId(record.mId, isDeleted);
|
||||
}
|
||||
|
@ -235,28 +230,20 @@ namespace MWWorld
|
|||
if(it == mStatic.end())
|
||||
return nullptr;
|
||||
}
|
||||
std::pair<typename Dynamic::iterator, bool> result =
|
||||
mDynamic.insert(std::pair<std::string, T>(id, item));
|
||||
std::pair<typename Dynamic::iterator, bool> result = mDynamic.insert_or_assign(id, item);
|
||||
T *ptr = &result.first->second;
|
||||
if (result.second) {
|
||||
if (result.second)
|
||||
mShared.push_back(ptr);
|
||||
} else {
|
||||
*ptr = item;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
template<typename T>
|
||||
T *Store<T>::insertStatic(const T &item)
|
||||
{
|
||||
std::string id = Misc::StringUtils::lowerCase(item.mId);
|
||||
std::pair<typename Static::iterator, bool> result =
|
||||
mStatic.insert(std::pair<std::string, T>(id, item));
|
||||
std::pair<typename Static::iterator, bool> result = mStatic.insert_or_assign(id, item);
|
||||
T *ptr = &result.first->second;
|
||||
if (result.second) {
|
||||
if (result.second)
|
||||
mShared.push_back(ptr);
|
||||
} else {
|
||||
*ptr = item;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
template<typename T>
|
||||
|
|
Loading…
Reference in a new issue