1
0
forked from 0ad/0ad

Remove a division by a fixed equal to one in NearestNavcell in the short-range pathfinder which was from profiling on VC2013/windows 7 responsible for about 10% of ComputeShortPath.

This was SVN commit r18358.
This commit is contained in:
wraitii 2016-06-10 22:57:28 +00:00
parent c94cd66a57
commit 001c411cc2

View File

@ -144,8 +144,11 @@ namespace Pathfinding
*/
inline void NearestNavcell(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h)
{
i = (u16)clamp((x / NAVCELL_SIZE).ToInt_RoundToNegInfinity(), 0, w - 1);
j = (u16)clamp((z / NAVCELL_SIZE).ToInt_RoundToNegInfinity(), 0, h - 1);
// x, z should be divided by NAVCELL_SIZE but that value happens to be 1 for now
// Since this is an i64 division and rather slow (10% of ComputeShortPath), cut it out
cassert(NAVCELL_SIZE_INT == 1);
i = (u16)clamp(x.ToInt_RoundToNegInfinity(), 0, w - 1);
j = (u16)clamp(z.ToInt_RoundToNegInfinity(), 0, h - 1);
}
/**