mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 04:17:07 +00:00
BlockStateUpgradeSchema: avoid unnecessary property access and calculation
this was costing a surprisingly large 5-10% of the processing time for blockstate data.
This commit is contained in:
parent
ac8dbf8640
commit
8ec304e66e
@ -64,20 +64,24 @@ final class BlockStateUpgradeSchema{
|
|||||||
*/
|
*/
|
||||||
public array $remappedStates = [];
|
public array $remappedStates = [];
|
||||||
|
|
||||||
|
public readonly int $versionId;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public int $maxVersionMajor,
|
public readonly int $maxVersionMajor,
|
||||||
public int $maxVersionMinor,
|
public readonly int $maxVersionMinor,
|
||||||
public int $maxVersionPatch,
|
public readonly int $maxVersionPatch,
|
||||||
public int $maxVersionRevision,
|
public readonly int $maxVersionRevision,
|
||||||
private int $schemaId
|
private int $schemaId
|
||||||
){}
|
){
|
||||||
|
$this->versionId = ($this->maxVersionMajor << 24) | ($this->maxVersionMinor << 16) | ($this->maxVersionPatch << 8) | $this->maxVersionRevision;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This is defined by Mojang, and therefore cannot be relied on. Use getSchemaId() instead for
|
* @deprecated This is defined by Mojang, and therefore cannot be relied on. Use getSchemaId() instead for
|
||||||
* internal version management.
|
* internal version management.
|
||||||
*/
|
*/
|
||||||
public function getVersionId() : int{
|
public function getVersionId() : int{
|
||||||
return ($this->maxVersionMajor << 24) | ($this->maxVersionMinor << 16) | ($this->maxVersionPatch << 8) | $this->maxVersionRevision;
|
return $this->versionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSchemaId() : int{ return $this->schemaId; }
|
public function getSchemaId() : int{ return $this->schemaId; }
|
||||||
|
@ -62,7 +62,7 @@ final class BlockStateUpgrader{
|
|||||||
$version = $blockStateData->getVersion();
|
$version = $blockStateData->getVersion();
|
||||||
$highestVersion = $version;
|
$highestVersion = $version;
|
||||||
foreach($this->upgradeSchemas as $schema){
|
foreach($this->upgradeSchemas as $schema){
|
||||||
$resultVersion = $schema->getVersionId();
|
$resultVersion = $schema->versionId;
|
||||||
$highestVersion = max($highestVersion, $resultVersion);
|
$highestVersion = max($highestVersion, $resultVersion);
|
||||||
if($version > $resultVersion){
|
if($version > $resultVersion){
|
||||||
//even if this is actually the same version, we have to apply it anyway because mojang are dumb and
|
//even if this is actually the same version, we have to apply it anyway because mojang are dumb and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user