1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 18:53:54 +00:00

Merge pull request #2574 from Capostrophic/cellrefid

Avoid copying strings in SearchVisitor and readReferenceCollection (#5195)
This commit is contained in:
Bret Curtis 2019-10-28 23:32:03 +01:00 committed by GitHub
commit 9655da81a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View file

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

View file

@ -34,6 +34,9 @@ namespace MWWorld
// Id of object being referenced // Id of object being referenced
std::string getRefId() const; 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 // For doors - true if this door teleports to somewhere else, false
// if it should open through animation. // if it should open through animation.
bool getTeleport() const; bool getTeleport() const;

View file

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