del[char]: delete unused char serialization method

This commit is contained in:
godotg
2023-10-06 09:13:01 +08:00
parent a68be0a916
commit de496ff7ae
2 changed files with 3 additions and 64 deletions
@@ -406,28 +406,6 @@ public abstract class ByteBufUtils {
}
//---------------------------------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 abstract class ByteBufUtils {
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 <T> void writePacketArray(ByteBuf byteBuf, T[] array, IProtocolRegistration protocolRegistration) {
if (array == null) {
byteBuf.writeByte(0);
@@ -60,6 +60,9 @@ public class NormalObject {
// @Compatible(1)
// public int outCompatibleValue;
// @Compatible(2)
// public int outCompatibleValue2;