From de496ff7aebe931db587e1a01a6c30e8fe79134f Mon Sep 17 00:00:00 2001 From: godotg Date: Fri, 6 Oct 2023 09:13:01 +0800 Subject: [PATCH] del[char]: delete unused char serialization method --- .../zfoo/protocol/buffer/ByteBufUtils.java | 64 ------------------- .../zfoo/protocol/packet/NormalObject.java | 3 + 2 files changed, 3 insertions(+), 64 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 f362bebbe..6267130b1 100644 --- a/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java @@ -406,28 +406,6 @@ public static String readString(ByteBuf byteBuf) { } - //---------------------------------char-------------------------------------- - // 很多脚本语言没有char,所以这里使用string代替 - public static void writeChar(ByteBuf byteBuf, char value) { - writeString(byteBuf, String.valueOf(value)); - } - - public static char readChar(ByteBuf byteBuf) { - var value = readString(byteBuf); - if (StringUtils.isEmpty(value)) { - return Character.MIN_VALUE; - } - return value.charAt(0); - } - - public static void writeCharBox(ByteBuf byteBuf, Character value) { - writeChar(byteBuf, value == null ? Character.MIN_VALUE : value); - } - - public static Character readCharBox(ByteBuf byteBuf) { - return readChar(byteBuf); - } - //----------------------------------------------------------------------- //---------------------------------以下方法会被字节码生成的代码调用-------------------------------------- public static void writePacketCollection(ByteBuf byteBuf, Collection collection, IProtocolRegistration protocolRegistration) { @@ -1319,48 +1297,6 @@ public static Set readStringSet(ByteBuf byteBuf) { return set; } - - //---------------------------------char-------------------------------------- - public static void writeCharArray(ByteBuf byteBuf, char[] array) { - if (array == null) { - byteBuf.writeByte(0); - return; - } - writeInt(byteBuf, array.length); - for (var value : array) { - writeChar(byteBuf, value); - } - } - - public static char[] readCharArray(ByteBuf byteBuf) { - var length = readInt(byteBuf); - var chars = new char[CollectionUtils.comfortableLength(length)]; - for (var i = 0; i < length; i++) { - chars[i] = readChar(byteBuf); - } - return chars; - } - - public static void writeCharBoxArray(ByteBuf byteBuf, Character[] array) { - if (array == null) { - byteBuf.writeByte(0); - return; - } - writeInt(byteBuf, array.length); - for (var value : array) { - writeCharBox(byteBuf, value); - } - } - - public static Character[] readCharBoxArray(ByteBuf byteBuf) { - var length = readInt(byteBuf); - var chars = new Character[CollectionUtils.comfortableLength(length)]; - for (var i = 0; i < length; i++) { - chars[i] = readCharBox(byteBuf); - } - return chars; - } - public static void writePacketArray(ByteBuf byteBuf, T[] array, IProtocolRegistration protocolRegistration) { if (array == null) { byteBuf.writeByte(0); diff --git a/protocol/src/test/java/com/zfoo/protocol/packet/NormalObject.java b/protocol/src/test/java/com/zfoo/protocol/packet/NormalObject.java index 81d84ac83..94dff20f5 100644 --- a/protocol/src/test/java/com/zfoo/protocol/packet/NormalObject.java +++ b/protocol/src/test/java/com/zfoo/protocol/packet/NormalObject.java @@ -60,6 +60,9 @@ public class NormalObject { // @Compatible(1) // public int outCompatibleValue; + + + // @Compatible(2) // public int outCompatibleValue2;