@@ -64,10 +64,10 @@ public Bytes encode(final Bytes bytes) {
6464 if (bytes .size () == 1 && Byte .toUnsignedInt (bytes .get (0 )) <= MAXIMUM_STANDALONE_BYTE_VALUE ) {
6565 return bytes ;
6666 } else if (bytes .size () <= LENGTH_THRESHOLD ) {
67- return Bytes .concatenate (SHORT_STRING_LENGTHS [bytes .size ()], bytes );
67+ return Bytes .wrap (SHORT_STRING_LENGTHS [bytes .size ()], bytes );
6868 } else { // bytes.size > LENGTH_THRESHOLD
6969 Bytes length = Bytes .minimalBytes (bytes .size ());
70- return Bytes .concatenate (LONG_STRING_LENGTHS [length .size ()], length , bytes );
70+ return Bytes .wrap (LONG_STRING_LENGTHS [length .size ()], length , bytes );
7171 }
7272 }
7373
@@ -81,12 +81,10 @@ public Bytes encodeList(final List<Bytes> encodedBytesList) {
8181 int totalLength = encodedBytesList .stream ().mapToInt (Bytes ::size ).sum ();
8282
8383 if (totalLength <= LENGTH_THRESHOLD ) {
84- return Bytes .concatenate (
85- SHORT_LIST_LENGTHS [totalLength ], Bytes .concatenate (encodedBytesList ));
84+ return Bytes .wrap (SHORT_LIST_LENGTHS [totalLength ], Bytes .wrap (encodedBytesList ));
8685 } else { // totalLength > LENGTH_THRESHOLD
8786 Bytes length = Bytes .minimalBytes (totalLength );
88- return Bytes .concatenate (
89- LONG_LIST_LENGTHS [length .size ()], length , Bytes .concatenate (encodedBytesList ));
87+ return Bytes .wrap (LONG_LIST_LENGTHS [length .size ()], length , Bytes .wrap (encodedBytesList ));
9088 }
9189 }
9290}
0 commit comments