diff --git a/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java b/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java index 5e2bd816..3ce7db6a 100644 --- a/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java @@ -13,8 +13,7 @@ package com.zfoo.protocol.buffer; import com.zfoo.protocol.IPacket; -import com.zfoo.protocol.collection.ArrayUtils; -import com.zfoo.protocol.collection.CollectionUtils; +import com.zfoo.protocol.collection.*; import com.zfoo.protocol.registration.IProtocolRegistration; import com.zfoo.protocol.util.StringUtils; import io.netty.buffer.ByteBuf; @@ -754,9 +753,9 @@ public abstract class ByteBufUtils { public static List readBooleanList(ByteBuf byteBuf) { var length = readInt(byteBuf); - var list = (List) CollectionUtils.newFixedList(length); + var list = new FixedSizeBooleanList(length); for (var i = 0; i < length; i++) { - list.add(readBooleanBox(byteBuf)); + list.set(i, readBoolean(byteBuf)); } return list; } @@ -918,9 +917,9 @@ public abstract class ByteBufUtils { public static List readShortList(ByteBuf byteBuf) { var length = readInt(byteBuf); - var list = (List) CollectionUtils.newFixedList(length); + var list = new FixedSizeShortList(length); for (var i = 0; i < length; i++) { - list.add(readShortBox(byteBuf)); + list.set(i, readShort(byteBuf)); } return list; } @@ -997,9 +996,9 @@ public abstract class ByteBufUtils { public static List readIntList(ByteBuf byteBuf) { var length = readInt(byteBuf); - var list = (List) CollectionUtils.newFixedList(length); + var list = new FixedSizeIntList(length); for (var i = 0; i < length; i++) { - list.add(readIntBox(byteBuf)); + list.set(i, readInt(byteBuf)); } return list; } @@ -1076,9 +1075,9 @@ public abstract class ByteBufUtils { public static List readLongList(ByteBuf byteBuf) { var length = readInt(byteBuf); - var list = (List) CollectionUtils.newFixedList(length); + var list = new FixedSizeLongList(length); for (var i = 0; i < length; i++) { - list.add(readLongBox(byteBuf)); + list.set(i, readLong(byteBuf)); } return list; } @@ -1162,9 +1161,9 @@ public abstract class ByteBufUtils { public static List readFloatList(ByteBuf byteBuf) { var length = readInt(byteBuf); - var list = (List) CollectionUtils.newFixedList(length); + var list = new FixedSizeFloatList(length); for (var i = 0; i < length; i++) { - list.add(readFloatBox(byteBuf)); + list.set(i, readFloat(byteBuf)); } return list; } @@ -1248,9 +1247,9 @@ public abstract class ByteBufUtils { public static List readDoubleList(ByteBuf byteBuf) { var length = readInt(byteBuf); - var list = (List) CollectionUtils.newFixedList(length); + var list = new FixedSizeDoubleList(length); for (var i = 0; i < length; i++) { - list.add(readDoubleBox(byteBuf)); + list.set(i, readDouble(byteBuf)); } return list; } @@ -1306,9 +1305,9 @@ public abstract class ByteBufUtils { public static List readStringList(ByteBuf byteBuf) { var length = readInt(byteBuf); - var list = (List) CollectionUtils.newFixedList(length); + var list = new FixedSizeStringList(length); for (var i = 0; i < length; i++) { - list.add(readString(byteBuf)); + list.set(i, readString(byteBuf)); } return list; }