perf[buffer]: 自定义私有协议格式,可以针对性的对存在性能瓶颈的数据结构做特定优化

This commit is contained in:
godotg
2022-10-21 10:25:06 +08:00
parent 2962f56cd8
commit 8e7ea2c1fc
@@ -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;
}
}