Skip to content

Commit

Permalink
Improve Npc::getRandomStep cache (#3734)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramon-bernardo authored Oct 31, 2021
1 parent 95de3cc commit ebfbef9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,9 @@ bool Npc::canWalkTo(const Position& fromPos, Direction dir) const
bool Npc::getRandomStep(Direction& dir) const
{
std::vector<Direction> dirList;
const Position& creaturePos = getPosition();
dirList.reserve(4);

const Position& creaturePos = getPosition();
if (canWalkTo(creaturePos, DIRECTION_NORTH)) {
dirList.push_back(DIRECTION_NORTH);
}
Expand Down

0 comments on commit ebfbef9

Please sign in to comment.