mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +00:00
Level: Change isInWorld signature to use ints instead of floats
this is only used in one place, where it's being given floats, and it's 10% faster to use int for this because it won't convert it. It is also 25% faster to remove typehints and 60% faster to inline it. We really need a proper PHP preprocessor for inlining.
This commit is contained in:
parent
22b91aaa24
commit
29fd26627e
@ -142,11 +142,11 @@ interface ChunkManager{
|
|||||||
* Returns whether the specified coordinates are within the valid world boundaries, taking world format limitations
|
* Returns whether the specified coordinates are within the valid world boundaries, taking world format limitations
|
||||||
* into account.
|
* into account.
|
||||||
*
|
*
|
||||||
* @param float $x
|
* @param int $x
|
||||||
* @param float $y
|
* @param int $y
|
||||||
* @param float $z
|
* @param int $z
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isInWorld(float $x, float $y, float $z) : bool;
|
public function isInWorld(int $x, int $y, int $z) : bool;
|
||||||
}
|
}
|
||||||
|
@ -1318,7 +1318,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
return $this->getChunk($x >> 4, $z >> 4, false)->getFullBlock($x & 0x0f, $y, $z & 0x0f);
|
return $this->getChunk($x >> 4, $z >> 4, false)->getFullBlock($x & 0x0f, $y, $z & 0x0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isInWorld(float $x, float $y, float $z) : bool{
|
public function isInWorld(int $x, int $y, int $z) : bool{
|
||||||
return (
|
return (
|
||||||
$x <= INT32_MAX and $x >= INT32_MIN and
|
$x <= INT32_MAX and $x >= INT32_MIN and
|
||||||
$y < $this->worldHeight and $y >= 0 and
|
$y < $this->worldHeight and $y >= 0 and
|
||||||
|
@ -172,7 +172,7 @@ class SimpleChunkManager implements ChunkManager{
|
|||||||
return $this->worldHeight;
|
return $this->worldHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isInWorld(float $x, float $y, float $z) : bool{
|
public function isInWorld(int $x, int $y, int $z) : bool{
|
||||||
return (
|
return (
|
||||||
$x <= INT32_MAX and $x >= INT32_MIN and
|
$x <= INT32_MAX and $x >= INT32_MIN and
|
||||||
$y < $this->worldHeight and $y >= 0 and
|
$y < $this->worldHeight and $y >= 0 and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user