Limit SubChunk to 2 layers, avoid arrays (#6747)

Initially proposed in #6575

This shows about a 10% performance improvement to both SubChunk->getBlockStateId() and SubChunk->setBlockStateId(), so definitely worth doing. It does result in increased complexity, but for a double digits performance gain, I think it's worth it.

Closes #6575
This commit is contained in:
Dylan T.
2025-09-27 18:51:15 +01:00
committed by GitHub
parent 9eadf59bf5
commit 7ec548774c
10 changed files with 104 additions and 76 deletions

View File

@@ -94,7 +94,7 @@ trait LegacyAnvilChunkTrait{
}
for($y = Chunk::MIN_SUBCHUNK_INDEX; $y <= Chunk::MAX_SUBCHUNK_INDEX; ++$y){
if(!isset($subChunks[$y])){
$subChunks[$y] = new SubChunk(Block::EMPTY_STATE_ID, [], clone $biomes3d);
$subChunks[$y] = new SubChunk(Block::EMPTY_STATE_ID, null, null, clone $biomes3d);
}
}