mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 03:51:37 +00:00
ItemSerializer: avoid slow NBT check
hasNamedTag() rebuilds the NBT from item properties to decide if there's any NBT. This is a waste of resources when we then fetch the tag to encode anyway.
This commit is contained in:
@@ -117,8 +117,8 @@ final class ItemSerializer{
|
|||||||
$data = $serializer($item);
|
$data = $serializer($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($item->hasNamedTag()){
|
$resultTag = $item->getNamedTag();
|
||||||
$resultTag = $item->getNamedTag();
|
if($resultTag->count() > 0){
|
||||||
$extraTag = $data->getTag();
|
$extraTag = $data->getTag();
|
||||||
if($extraTag !== null){
|
if($extraTag !== null){
|
||||||
$resultTag = $resultTag->merge($extraTag);
|
$resultTag = $resultTag->merge($extraTag);
|
||||||
|
Reference in New Issue
Block a user