mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-06-01 08:13:50 +00:00
perf[protocol]: 序列化空的char使用空的字符串代替
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user