mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-31 15:31:07 +00:00
SubChunk: workaround opcache preloading constant issue
non-class constants aren't stored during preloading phase and for some reason they aren't pre-resolved in opcode arrays. However, they are resolved by value when referenced by class constants, and class constants stick, so we can use those instead.
This commit is contained in:
parent
f9c2ed6200
commit
d2f1a3cf5b
@ -38,6 +38,8 @@ if(!defined(__NAMESPACE__ . '\ZERO_NIBBLE_ARRAY')){
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SubChunk implements SubChunkInterface{
|
class SubChunk implements SubChunkInterface{
|
||||||
|
private const ZERO_NIBBLE_ARRAY = ZERO_NIBBLE_ARRAY;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $ids;
|
protected $ids;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
@ -68,7 +70,7 @@ class SubChunk implements SubChunkInterface{
|
|||||||
substr_count($this->ids, "\x00") === 4096 and
|
substr_count($this->ids, "\x00") === 4096 and
|
||||||
(!$checkLight or (
|
(!$checkLight or (
|
||||||
substr_count($this->skyLight, "\xff") === 2048 and
|
substr_count($this->skyLight, "\xff") === 2048 and
|
||||||
$this->blockLight === ZERO_NIBBLE_ARRAY
|
$this->blockLight === self::ZERO_NIBBLE_ARRAY
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -230,14 +232,14 @@ class SubChunk implements SubChunkInterface{
|
|||||||
* reference to the const instead of duplicating the whole string. The string will only be duplicated when
|
* reference to the const instead of duplicating the whole string. The string will only be duplicated when
|
||||||
* modified, which is perfect for this purpose.
|
* modified, which is perfect for this purpose.
|
||||||
*/
|
*/
|
||||||
if($this->data === ZERO_NIBBLE_ARRAY){
|
if($this->data === self::ZERO_NIBBLE_ARRAY){
|
||||||
$this->data = ZERO_NIBBLE_ARRAY;
|
$this->data = self::ZERO_NIBBLE_ARRAY;
|
||||||
}
|
}
|
||||||
if($this->skyLight === ZERO_NIBBLE_ARRAY){
|
if($this->skyLight === self::ZERO_NIBBLE_ARRAY){
|
||||||
$this->skyLight = ZERO_NIBBLE_ARRAY;
|
$this->skyLight = self::ZERO_NIBBLE_ARRAY;
|
||||||
}
|
}
|
||||||
if($this->blockLight === ZERO_NIBBLE_ARRAY){
|
if($this->blockLight === self::ZERO_NIBBLE_ARRAY){
|
||||||
$this->blockLight = ZERO_NIBBLE_ARRAY;
|
$this->blockLight = self::ZERO_NIBBLE_ARRAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user