Skip to content

Commit

Permalink
del[char]: delete unused char serialization method
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Oct 6, 2023
1 parent a68be0a commit de496ff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 64 deletions.
64 changes: 0 additions & 64 deletions protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1319,48 +1297,6 @@ public static Set<String> 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 <T> void writePacketArray(ByteBuf byteBuf, T[] array, IProtocolRegistration protocolRegistration) {
if (array == null) {
byteBuf.writeByte(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public class NormalObject {

// @Compatible(1)
// public int outCompatibleValue;



// @Compatible(2)
// public int outCompatibleValue2;

Expand Down

0 comments on commit de496ff

Please sign in to comment.