mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:23:52 +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);
|
record.load(esm, isDeleted);
|
||||||
|
|
||||||
// Try to overwrite existing record
|
mStatic.insert_or_assign(record.mIndex, record);
|
||||||
std::pair<typename Static::iterator, bool> ret = mStatic.insert(std::make_pair(record.mIndex, record));
|
|
||||||
if (!ret.second)
|
|
||||||
ret.first->second = record;
|
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
int IndexedStore<T>::getSize() const
|
int IndexedStore<T>::getSize() const
|
||||||
|
@ -181,11 +178,9 @@ namespace MWWorld
|
||||||
record.load(esm, isDeleted);
|
record.load(esm, isDeleted);
|
||||||
Misc::StringUtils::lowerCaseInPlace(record.mId);
|
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)
|
if (inserted.second)
|
||||||
mShared.push_back(&inserted.first->second);
|
mShared.push_back(&inserted.first->second);
|
||||||
else
|
|
||||||
inserted.first->second = record;
|
|
||||||
|
|
||||||
return RecordId(record.mId, isDeleted);
|
return RecordId(record.mId, isDeleted);
|
||||||
}
|
}
|
||||||
|
@ -235,28 +230,20 @@ namespace MWWorld
|
||||||
if(it == mStatic.end())
|
if(it == mStatic.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
std::pair<typename Dynamic::iterator, bool> result =
|
std::pair<typename Dynamic::iterator, bool> result = mDynamic.insert_or_assign(id, item);
|
||||||
mDynamic.insert(std::pair<std::string, T>(id, item));
|
|
||||||
T *ptr = &result.first->second;
|
T *ptr = &result.first->second;
|
||||||
if (result.second) {
|
if (result.second)
|
||||||
mShared.push_back(ptr);
|
mShared.push_back(ptr);
|
||||||
} else {
|
|
||||||
*ptr = item;
|
|
||||||
}
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T *Store<T>::insertStatic(const T &item)
|
T *Store<T>::insertStatic(const T &item)
|
||||||
{
|
{
|
||||||
std::string id = Misc::StringUtils::lowerCase(item.mId);
|
std::string id = Misc::StringUtils::lowerCase(item.mId);
|
||||||
std::pair<typename Static::iterator, bool> result =
|
std::pair<typename Static::iterator, bool> result = mStatic.insert_or_assign(id, item);
|
||||||
mStatic.insert(std::pair<std::string, T>(id, item));
|
|
||||||
T *ptr = &result.first->second;
|
T *ptr = &result.first->second;
|
||||||
if (result.second) {
|
if (result.second)
|
||||||
mShared.push_back(ptr);
|
mShared.push_back(ptr);
|
||||||
} else {
|
|
||||||
*ptr = item;
|
|
||||||
}
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in a new issue