mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-19 15:35:52 +00:00
World: use new Vector3() instead of Block->getPosition()
When profiling this, I noticed that we spend a stupidly large amount of time creating useless Position objects in the case of update=true, because Vector3->sides() calls Position->getSide(), which calls Position::fromObject(parent::getSide()). This is stupid because the update logic doesn't require Positions anywhere (as evidenced by this change needing no other alterations. A rough profile shows that this improves setBlock() performance by about 25% in the update=true case, which is a pretty big margin. As an added bonus, it gets rid of some unrealized cyclic dependencies in World->changedBlocks.
This commit is contained in:
parent
0f6b7e48cb
commit
c17587d436
@ -1600,7 +1600,7 @@ class World implements ChunkManager{
|
||||
|
||||
$block->position($this, $x, $y, $z);
|
||||
$block->writeStateToWorld();
|
||||
$pos = $block->getPosition();
|
||||
$pos = new Vector3($x, $y, $z);
|
||||
|
||||
$chunkHash = World::chunkHash($chunkX, $chunkZ);
|
||||
$relativeBlockHash = World::chunkBlockHash($x, $y, $z);
|
||||
|
Loading…
x
Reference in New Issue
Block a user