Replaced usages of Math::floorFloat() with (int) floor() and Math::ceilFloat() with (int) ceil()

Once upon a time, these userland functions were faster than calling builtins, but not anymore. According to my test the Math functions are twice slower in PHP 7.2 with typehints and 50% slower without typehints.

Inlining is slightly faster than using builtins, but the difference is very small - not worth making the code look any more ugly than it does already.
This commit is contained in:
Dylan K. Taylor
2018-05-28 18:54:35 +01:00
parent 71fdd59c4c
commit 4f8f334436
3 changed files with 42 additions and 42 deletions

View File

@ -164,12 +164,12 @@ class Explosion{
}
$explosionSize = $this->size * 2;
$minX = Math::floorFloat($this->source->x - $explosionSize - 1);
$maxX = Math::ceilFloat($this->source->x + $explosionSize + 1);
$minY = Math::floorFloat($this->source->y - $explosionSize - 1);
$maxY = Math::ceilFloat($this->source->y + $explosionSize + 1);
$minZ = Math::floorFloat($this->source->z - $explosionSize - 1);
$maxZ = Math::ceilFloat($this->source->z + $explosionSize + 1);
$minX = (int) floor($this->source->x - $explosionSize - 1);
$maxX = (int) ceil($this->source->x + $explosionSize + 1);
$minY = (int) floor($this->source->y - $explosionSize - 1);
$maxY = (int) ceil($this->source->y + $explosionSize + 1);
$minZ = (int) floor($this->source->z - $explosionSize - 1);
$maxZ = (int) ceil($this->source->z + $explosionSize + 1);
$explosionBB = new AxisAlignedBB($minX, $minY, $minZ, $maxX, $maxY, $maxZ);