mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 21:45:35 +00:00
ChunkSerializer micro optimisation: reduce indirections when writing runtime IDs
This commit is contained in:
parent
0188323d74
commit
ad99dc5884
@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\serializer;
|
|||||||
use pocketmine\block\tile\Spawnable;
|
use pocketmine\block\tile\Spawnable;
|
||||||
use pocketmine\network\mcpe\convert\RuntimeBlockMapping;
|
use pocketmine\network\mcpe\convert\RuntimeBlockMapping;
|
||||||
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
|
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
|
||||||
|
use pocketmine\utils\Binary;
|
||||||
use pocketmine\utils\BinaryStream;
|
use pocketmine\utils\BinaryStream;
|
||||||
use pocketmine\world\format\Chunk;
|
use pocketmine\world\format\Chunk;
|
||||||
use function count;
|
use function count;
|
||||||
@ -70,7 +71,7 @@ final class ChunkSerializer{
|
|||||||
//zigzag and just shift directly.
|
//zigzag and just shift directly.
|
||||||
$stream->putUnsignedVarInt(count($palette) << 1); //yes, this is intentionally zigzag
|
$stream->putUnsignedVarInt(count($palette) << 1); //yes, this is intentionally zigzag
|
||||||
foreach($palette as $p){
|
foreach($palette as $p){
|
||||||
$stream->putUnsignedVarInt($blockMapper->toRuntimeId($p >> 4, $p & 0xf) << 1);
|
$stream->put(Binary::writeUnsignedVarInt($blockMapper->toRuntimeId($p >> 4, $p & 0xf) << 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user