perf[protocol]: 序列化空的char使用空的字符串代替

This commit is contained in:
jaysunxiao
2021-10-13 20:56:59 +08:00
parent 09ec7c60e6
commit 7a3695c442
@@ -368,15 +368,19 @@ public abstract class ByteBufUtils {
}
public static char readChar(ByteBuf byteBuf) {
return readString(byteBuf).charAt(0);
var value = readString(byteBuf);
if (StringUtils.isEmpty(value)) {
return Character.MIN_VALUE;
}
return value.charAt(0);
}
public static void writeCharBox(ByteBuf byteBuf, Character value) {
writeString(byteBuf, String.valueOf(value == null ? Character.MIN_VALUE : value));
writeChar(byteBuf, value == null ? Character.MIN_VALUE : value);
}
public static Character readCharBox(ByteBuf byteBuf) {
return readString(byteBuf).charAt(0);
return readChar(byteBuf);
}
//-----------------------------------------------------------------------