1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-06 06:45:35 +00:00

Merge branch 'hashRefID' into 'master'

Remove string copy in CellStore::search

See merge request OpenMW/openmw!77
This commit is contained in:
Andrei Kortunov 2019-04-24 16:46:13 +00:00
commit 28252bb359

View file

@ -382,10 +382,10 @@ namespace MWWorld
struct SearchVisitor struct SearchVisitor
{ {
PtrType mFound; PtrType mFound;
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().getRefId() == *mIdToFind)
{ {
mFound = ptr; mFound = ptr;
return false; return false;
@ -397,7 +397,7 @@ namespace MWWorld
Ptr CellStore::search (const std::string& id) Ptr CellStore::search (const std::string& id)
{ {
SearchVisitor<MWWorld::Ptr> searchVisitor; SearchVisitor<MWWorld::Ptr> searchVisitor;
searchVisitor.mIdToFind = id; searchVisitor.mIdToFind = &id;
forEach(searchVisitor); forEach(searchVisitor);
return searchVisitor.mFound; return searchVisitor.mFound;
} }
@ -405,7 +405,7 @@ namespace MWWorld
ConstPtr CellStore::searchConst (const std::string& id) const ConstPtr CellStore::searchConst (const std::string& id) const
{ {
SearchVisitor<MWWorld::ConstPtr> searchVisitor; SearchVisitor<MWWorld::ConstPtr> searchVisitor;
searchVisitor.mIdToFind = id; searchVisitor.mIdToFind = &id;
forEachConst(searchVisitor); forEachConst(searchVisitor);
return searchVisitor.mFound; return searchVisitor.mFound;
} }