mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Abuse property visibility to micro optimize CompoundTags
this produced a little less than 10% performance improvement under xdebug, and while the real-time benefit is negligible, it's harmless to have.
This commit is contained in:
parent
55a1731da3
commit
554096953b
@ -59,7 +59,7 @@ class CompoundTag extends NamedTag implements \ArrayAccess{
|
|||||||
if(is_array($value)){
|
if(is_array($value)){
|
||||||
foreach($value as $name => $tag){
|
foreach($value as $name => $tag){
|
||||||
if($tag instanceof NamedTag){
|
if($tag instanceof NamedTag){
|
||||||
$this->{$tag->getName()} = $tag;
|
$this->{$tag->__name} = $tag;
|
||||||
}else{
|
}else{
|
||||||
throw new \TypeError("CompoundTag members must be NamedTags, got " . gettype($tag) . " in given array");
|
throw new \TypeError("CompoundTag members must be NamedTags, got " . gettype($tag) . " in given array");
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ class CompoundTag extends NamedTag implements \ArrayAccess{
|
|||||||
* @param NamedTag $tag
|
* @param NamedTag $tag
|
||||||
*/
|
*/
|
||||||
public function setTag(NamedTag $tag) : void{
|
public function setTag(NamedTag $tag) : void{
|
||||||
$this->{$tag->getName()} = $tag;
|
$this->{$tag->__name} = $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -400,8 +400,8 @@ class CompoundTag extends NamedTag implements \ArrayAccess{
|
|||||||
$this->value = [];
|
$this->value = [];
|
||||||
do{
|
do{
|
||||||
$tag = $nbt->readTag($network);
|
$tag = $nbt->readTag($network);
|
||||||
if($tag instanceof NamedTag and $tag->getName() !== ""){
|
if($tag instanceof NamedTag and $tag->__name !== ""){
|
||||||
$this->{$tag->getName()} = $tag;
|
$this->{$tag->__name} = $tag;
|
||||||
}
|
}
|
||||||
}while(!($tag instanceof EndTag) and !$nbt->feof());
|
}while(!($tag instanceof EndTag) and !$nbt->feof());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user