Skip to content

Commit

Permalink
Remove redundant padLefts when size is known
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmuszz committed Aug 18, 2024
1 parent ac14528 commit 671e693
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 671e693

Please sign in to comment.