mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-18 02:15:09 +00:00
perf[buffer]: 自定义私有协议格式,可以针对性的对存在性能瓶颈的数据结构做特定优化
This commit is contained in:
1 parent
2962f56cd8
commit
8e7ea2c1fc
1 file changed
+5
-1
@@ -74,7 +74,11 @@ public abstract class CustomByteBuf {
|
|||||||
var length = ByteBufUtils.readInt(byteBuf);
|
var length = ByteBufUtils.readInt(byteBuf);
|
||||||
var byteBuffer = ByteBuffer.allocate(length * 4);
|
var byteBuffer = ByteBuffer.allocate(length * 4);
|
||||||
byteBuf.readBytes(byteBuffer);
|
byteBuf.readBytes(byteBuffer);
|
||||||
|
byteBuffer.rewind();
|
||||||
var intBuffer = byteBuffer.asIntBuffer();
|
var intBuffer = byteBuffer.asIntBuffer();
|
||||||
return intBuffer.array();
|
int[] ints = new int[length];
|
||||||
|
intBuffer.get(ints);
|
||||||
|
return ints;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user