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:
Muqsit Rayyan 2022-02-16 05:32:12 +05:00 committed by GitHub
parent 55c744cc00
commit 55dfacea8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -659,8 +659,9 @@ class Item implements \JsonSerializable{
->setByte("Count", Binary::signByte($this->count))
->setShort("Damage", $this->getMeta());
if($this->hasNamedTag()){
$result->setTag("tag", $this->getNamedTag());
$tag = $this->getNamedTag();
if($tag->count() > 0){
$result->setTag("tag", $tag);
}
if($slot !== -1){