Slow SubChunk garbage collection check #6574
Labels
Category: Core
Related to internal functionality
Easy task
Probably really easy to do, good task for first-time contributors
Performance
Type: Enhancement
Contributes features or other improvements to PocketMine-MP
Problem description
PocketMine-MP/src/world/format/SubChunk.php
Line 137 in f7687af
getPalette()
is expensive on account of building a PHP array on the fly to return to user code.Proposed solution
This check could just check if
getBitsPerBlock() === 0
and ifget(0, 0, 0) === emptyBlockId
. No foreach required, althoughcollectGarbage()
must be called first.Alternative solutions
I considered that we could add
PalettedBlockArray::isUniform(int $value)
similar toLightArray
, but this seems unnecessary since it's easily doable with user code.The text was updated successfully, but these errors were encountered: