mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +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;
|
||||
|
||||
final class BlockStateDictionaryEntry{
|
||||
/**
|
||||
* @var string[]
|
||||
* @phpstan-var array<string, string>
|
||||
*/
|
||||
private static array $uniqueRawStates = [];
|
||||
|
||||
private string $rawStateProperties;
|
||||
|
||||
@ -44,7 +49,8 @@ final class BlockStateDictionaryEntry{
|
||||
array $stateProperties,
|
||||
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; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user