From 8e7ea2c1fcb5d8b39fb5d149180ba73036be7df1 Mon Sep 17 00:00:00 2001 From: godotg Date: Fri, 21 Oct 2022 10:25:06 +0800 Subject: [PATCH] =?UTF-8?q?perf[buffer]:=20=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=A7=81=E6=9C=89=E5=8D=8F=E8=AE=AE=E6=A0=BC=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E9=92=88=E5=AF=B9=E6=80=A7=E7=9A=84=E5=AF=B9?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E6=80=A7=E8=83=BD=E7=93=B6=E9=A2=88=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E5=81=9A=E7=89=B9=E5=AE=9A?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/zfoo/protocol/buffer/CustomByteBuf.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protocol/src/main/java/com/zfoo/protocol/buffer/CustomByteBuf.java b/protocol/src/main/java/com/zfoo/protocol/buffer/CustomByteBuf.java index f67f0399..92506074 100644 --- a/protocol/src/main/java/com/zfoo/protocol/buffer/CustomByteBuf.java +++ b/protocol/src/main/java/com/zfoo/protocol/buffer/CustomByteBuf.java @@ -74,7 +74,11 @@ public abstract class CustomByteBuf { var length = ByteBufUtils.readInt(byteBuf); var byteBuffer = ByteBuffer.allocate(length * 4); byteBuf.readBytes(byteBuffer); + byteBuffer.rewind(); var intBuffer = byteBuffer.asIntBuffer(); - return intBuffer.array(); + int[] ints = new int[length]; + intBuffer.get(ints); + return ints; } + }