From 28a72a93b47bd10a17f0a0e2ed0aa0d1618bcad5 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 5 Jul 2018 11:58:20 +0100 Subject: [PATCH] Chunk: Use an SplFixedArray for heightmap this goes on 3.1 because it changes the behaviour of chunk cloning, which might possibly break some plugins, and this isn't a bug fix. This should see no change in behaviour other than a minor performance improvement and slight reduction in memory usage. --- src/pocketmine/level/format/Chunk.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/level/format/Chunk.php b/src/pocketmine/level/format/Chunk.php index f1156a487..a373a2cd0 100644 --- a/src/pocketmine/level/format/Chunk.php +++ b/src/pocketmine/level/format/Chunk.php @@ -75,8 +75,8 @@ class Chunk{ /** @var Entity[] */ protected $entities = []; - /** @var int[] */ - protected $heightMap = []; + /** @var \SplFixedArray|int[] */ + protected $heightMap; /** @var string */ protected $biomeIds; @@ -110,11 +110,11 @@ class Chunk{ } if(count($heightMap) === 256){ - $this->heightMap = $heightMap; + $this->heightMap = \SplFixedArray::fromArray($heightMap); }else{ assert(count($heightMap) === 0, "Wrong HeightMap value count, expected 256, got " . count($heightMap)); $val = ($this->height * 16); - $this->heightMap = array_fill(0, 256, $val); + $this->heightMap = \SplFixedArray::fromArray(array_fill(0, 256, $val)); } if(strlen($biomeIds) === 256){ @@ -739,7 +739,7 @@ class Chunk{ * @return int[] */ public function getHeightMapArray() : array{ - return $this->heightMap; + return $this->heightMap->toArray(); } /**