mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-23 19:20:56 +00:00
Fix wasteful allocations in Store<Land>::search
This commit is contained in:
parent
72c6b11cf8
commit
a495b9b884
@ -38,6 +38,12 @@ namespace
|
|||||||
}
|
}
|
||||||
return x->mX < y->mX;
|
return x->mX < y->mX;
|
||||||
}
|
}
|
||||||
|
bool operator()(const ESM::Land *x, const std::pair<int, int>& y) {
|
||||||
|
if (x->mX == y.first) {
|
||||||
|
return x->mY < y.second;
|
||||||
|
}
|
||||||
|
return x->mX < y.first;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,11 +444,10 @@ namespace MWWorld
|
|||||||
}
|
}
|
||||||
const ESM::Land *Store<ESM::Land>::search(int x, int y) const
|
const ESM::Land *Store<ESM::Land>::search(int x, int y) const
|
||||||
{
|
{
|
||||||
ESM::Land land;
|
std::pair<int, int> comp(x,y);
|
||||||
land.mX = x, land.mY = y;
|
|
||||||
|
|
||||||
std::vector<ESM::Land *>::const_iterator it =
|
std::vector<ESM::Land *>::const_iterator it =
|
||||||
std::lower_bound(mStatic.begin(), mStatic.end(), &land, Compare());
|
std::lower_bound(mStatic.begin(), mStatic.end(), comp, Compare());
|
||||||
|
|
||||||
if (it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) {
|
if (it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) {
|
||||||
return *it;
|
return *it;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user