mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-12 20:16:07 +00:00
perf[protocol]: 序列化空的char使用空的字符串代替
This commit is contained in:
1 parent
09ec7c60e6
commit
7a3695c442
1 file changed
+7
-3
@@ -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