1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-01 00:45:32 +00:00

Avoid copying strings in SearchVisitor and readReferenceCollection

This commit is contained in:
Capostrophic 2019-10-28 19:28:14 +03:00
parent 0fa0e9571b
commit c6e431d862
3 changed files with 10 additions and 2 deletions

View file

@ -25,6 +25,11 @@ namespace MWWorld
return mCellRef.mRefID;
}
const std::string* CellRef::getRefIdPtr() const
{
return &mCellRef.mRefID;
}
bool CellRef::getTeleport() const
{
return mCellRef.mTeleport;

View file

@ -34,6 +34,9 @@ namespace MWWorld
// Id of object being referenced
std::string getRefId() const;
// Pointer to ID of the object being referenced
const std::string* getRefIdPtr() const;
// For doors - true if this door teleports to somewhere else, false
// if it should open through animation.
bool getTeleport() const;

View file

@ -137,7 +137,7 @@ namespace
{
for (typename MWWorld::CellRefList<T>::List::iterator iter (collection.mList.begin());
iter!=collection.mList.end(); ++iter)
if (iter->mRef.getRefNum()==state.mRef.mRefNum && iter->mRef.getRefId() == state.mRef.mRefID)
if (iter->mRef.getRefNum()==state.mRef.mRefNum && *iter->mRef.getRefIdPtr() == state.mRef.mRefID)
{
// overwrite existing reference
iter->load (state);
@ -390,7 +390,7 @@ namespace MWWorld
const std::string *mIdToFind;
bool operator()(const PtrType& ptr)
{
if (ptr.getCellRef().getRefId() == *mIdToFind)
if (*ptr.getCellRef().getRefIdPtr() == *mIdToFind)
{
mFound = ptr;
return false;