VarInt: simplify encode()

This commit is contained in:
Sean Gilligan 2023-03-27 06:39:20 -07:00 committed by Andreas Schildbach
parent 3746516859
commit 2aa764d403

View File

@ -150,9 +150,8 @@ public class VarInt {
* @return the minimal encoded bytes of the value
*/
public byte[] encode() {
byte[] bytes = new byte[sizeOf(value)];
write(ByteBuffer.wrap(bytes));
return bytes;
ByteBuffer buf = ByteBuffer.allocate(sizeOf(value));
return write(buf).array();
}
/**