Skip to content

Commit 8b47ca5

Browse files
authored
refactor(codec): remove intermediate byte array in ByteArrayInputStre… (#324)
…amCodec Signed-off-by: jchrys <jchrys@me.com>
1 parent 6492294 commit 8b47ca5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/codec/ByteArrayInputStreamCodec.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,13 @@ public Mono<ByteBuf> publishBinary(ByteBufAllocator allocator) {
8686

8787
try {
8888
VarIntUtils.writeVarInt(buf, size);
89-
90-
byte[] byteArray = new byte[size];
91-
int readBytes = value.read(byteArray);
92-
89+
int readBytes = buf.writeBytes(value, size);
9390
if (readBytes != size) {
9491
buf.release();
9592
throw new IllegalStateException("Expected to read " + size + " bytes, but got " + readBytes);
9693
}
9794

98-
return buf.writeBytes(byteArray);
95+
return buf;
9996
} catch (Exception e) {
10097
buf.release();
10198
throw new RuntimeException(e);

0 commit comments

Comments
 (0)