From 671e693598c9dd142ce07f5eddf70fe0e0d3c010 Mon Sep 17 00:00:00 2001 From: Mariusz Jakoniuk Date: Sun, 18 Aug 2024 21:13:38 +0200 Subject: [PATCH] Remove redundant `padLeft`s when size is known --- .../fs2/data/msgpack/low/internal/ItemSerializer.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/msgpack/src/main/scala/fs2/data/msgpack/low/internal/ItemSerializer.scala b/msgpack/src/main/scala/fs2/data/msgpack/low/internal/ItemSerializer.scala index 9495b7e8..9f49ad44 100644 --- a/msgpack/src/main/scala/fs2/data/msgpack/low/internal/ItemSerializer.scala +++ b/msgpack/src/main/scala/fs2/data/msgpack/low/internal/ItemSerializer.scala @@ -78,7 +78,7 @@ private[low] object ItemSerializer { val size = ByteVector.fromShort(bytes.size.toShort) ByteVector(Headers.Bin16).buffer ++ size ++ bytes } else { - val size = ByteVector.fromInt(bytes.size.toInt).padLeft(4) + val size = ByteVector.fromInt(bytes.size.toInt) ByteVector(Headers.Bin32).buffer ++ size ++ bytes } @@ -170,10 +170,10 @@ private[low] object ItemSerializer { ByteVector(Headers.Bin32) ++ size ++ item.bytes case item: MsgpackItem.Array => - ByteVector(Headers.Array32) ++ ByteVector.fromInt(item.size).padLeft(4) + ByteVector(Headers.Array32) ++ ByteVector.fromInt(item.size) case item: MsgpackItem.Map => - ByteVector(Headers.Map32) ++ ByteVector.fromInt(item.size).padLeft(4) + ByteVector(Headers.Map32) ++ ByteVector.fromInt(item.size) case item: MsgpackItem.Extension => val size = ByteVector.fromInt(item.bytes.size.toInt)