perf[buffer]: string读取用三目运算符优化

This commit is contained in:
jaysunxiao committed 2021-06-29 17:59:34 +08:00
1 parent ff6a896602
commit 7fc4519d4e
1 file changed
+1 -4
@@ -356,10 +356,7 @@ public abstract class ByteBufUtils {
public static String readString(ByteBuf byteBuf) {
int length = readInt(byteBuf);
if (length <= 0) {
return StringUtils.EMPTY;
}
return (String) byteBuf.readCharSequence(length, StringUtils.DEFAULT_CHARSET);
return length <= 0 ? StringUtils.EMPTY : (String) byteBuf.readCharSequence(length, StringUtils.DEFAULT_CHARSET);
}