From 5f6263e380c7dee7641b16192c6ded8d76fca2bc Mon Sep 17 00:00:00 2001 From: godotg Date: Fri, 7 Oct 2022 22:36:02 +0800 Subject: [PATCH] feat[serialization]: use primitive type hash map to deserialize --- .../com/zfoo/protocol/buffer/ByteBufUtils.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 f65bd55c..eccc9818 100644 --- a/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java @@ -451,9 +451,9 @@ public abstract class ByteBufUtils { public static Map readIntIntMap(ByteBuf byteBuf) { var length = readInt(byteBuf); - var map = new IntObjectHashMap(CollectionUtils.comfortableCapacity(length)); + var map = new HashMapIntInt(CollectionUtils.comfortableCapacity(length)); for (var i = 0; i < length; i++) { - map.put(readInt(byteBuf), readIntBox(byteBuf)); + map.putPrimitive(readInt(byteBuf), readInt(byteBuf)); } return map; } @@ -472,9 +472,9 @@ public abstract class ByteBufUtils { public static Map readIntLongMap(ByteBuf byteBuf) { var length = readInt(byteBuf); - var map = new IntObjectHashMap(CollectionUtils.comfortableCapacity(length)); + var map = new HashMapIntLong(CollectionUtils.comfortableCapacity(length)); for (var i = 0; i < length; i++) { - map.put(readInt(byteBuf), readLongBox(byteBuf)); + map.putPrimitive(readInt(byteBuf), readLong(byteBuf)); } return map; } @@ -535,9 +535,9 @@ public abstract class ByteBufUtils { public static Map readLongIntMap(ByteBuf byteBuf) { var length = readInt(byteBuf); - var map = new LongObjectHashMap(CollectionUtils.comfortableCapacity(length)); + var map = new HashMapLongInt(CollectionUtils.comfortableCapacity(length)); for (var i = 0; i < length; i++) { - map.put(readLong(byteBuf), readIntBox(byteBuf)); + map.putPrimitive(readLong(byteBuf), readInt(byteBuf)); } return map; } @@ -556,9 +556,9 @@ public abstract class ByteBufUtils { public static Map readLongLongMap(ByteBuf byteBuf) { var length = readInt(byteBuf); - var map = new LongObjectHashMap(CollectionUtils.comfortableCapacity(length)); + var map = new HashMapLongLong(CollectionUtils.comfortableCapacity(length)); for (var i = 0; i < length; i++) { - map.put(readLong(byteBuf), readLongBox(byteBuf)); + map.putPrimitive(readLong(byteBuf), readLong(byteBuf)); } return map; }