mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-21 04:25:00 +00:00
perf[buffer]: 自定义私有协议格式,可以针对性的对存在性能瓶颈的数据结构做特定优化
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user