mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 00:55:14 +00:00
Item: Improve performance of nbtSerialize() (#4831)
Replace hasNamedTag() with $nbt->count() > 0 This avoids a duplicate indirect call to Item::serializeCompoundTag() method call when serializing items with namedtags.
This commit is contained in:
@ -659,8 +659,9 @@ class Item implements \JsonSerializable{
|
|||||||
->setByte("Count", Binary::signByte($this->count))
|
->setByte("Count", Binary::signByte($this->count))
|
||||||
->setShort("Damage", $this->getMeta());
|
->setShort("Damage", $this->getMeta());
|
||||||
|
|
||||||
if($this->hasNamedTag()){
|
$tag = $this->getNamedTag();
|
||||||
$result->setTag("tag", $this->getNamedTag());
|
if($tag->count() > 0){
|
||||||
|
$result->setTag("tag", $tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($slot !== -1){
|
if($slot !== -1){
|
||||||
|
Reference in New Issue
Block a user