mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-13 13:25:16 +00:00
BlockStateDictionaryEntry: deduplicate encoded states
this saves about 500 KB of memory at no cost.
This commit is contained in:
parent
897ba9f2d9
commit
f1417e8dc9
@ -33,6 +33,11 @@ use function ksort;
|
|||||||
use const SORT_STRING;
|
use const SORT_STRING;
|
||||||
|
|
||||||
final class BlockStateDictionaryEntry{
|
final class BlockStateDictionaryEntry{
|
||||||
|
/**
|
||||||
|
* @var string[]
|
||||||
|
* @phpstan-var array<string, string>
|
||||||
|
*/
|
||||||
|
private static array $uniqueRawStates = [];
|
||||||
|
|
||||||
private string $rawStateProperties;
|
private string $rawStateProperties;
|
||||||
|
|
||||||
@ -44,7 +49,8 @@ final class BlockStateDictionaryEntry{
|
|||||||
array $stateProperties,
|
array $stateProperties,
|
||||||
private int $meta
|
private int $meta
|
||||||
){
|
){
|
||||||
$this->rawStateProperties = self::encodeStateProperties($stateProperties);
|
$rawStateProperties = self::encodeStateProperties($stateProperties);
|
||||||
|
$this->rawStateProperties = self::$uniqueRawStates[$rawStateProperties] ??= $rawStateProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStateName() : string{ return $this->stateName; }
|
public function getStateName() : string{ return $this->stateName; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user