mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
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:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user