LiangliangSui commented on code in PR #1591:
URL: https://github.com/apache/incubator-fury/pull/1591#discussion_r1582582106
##########
java/fury-core/src/main/java/org/apache/fury/meta/MetaStringDecoder.java:
##########
@@ -74,7 +74,7 @@ private String decodeLowerSpecial(byte[] data) {
boolean stripLastChar = (data[0] & 0x80) != 0; // Check the first bit of
the first byte
int bitMask = 0b11111; // 5 bits for the mask
int bitIndex = 1; // Start from the second bit
- while (bitIndex + 5 <= totalBits) {
+ while (bitIndex + 5 <= totalBits && !(stripLastChar && (bitIndex + 2 * 5 >
totalBits))) {
Review Comment:
`(bitIndex + 2 * 5 > totalBits)` indicates that the current character is the
last character.
`!(stripLastChar && (bitIndex + 2 * 5 > totalBits))` means that if the
current character is the last character and the last character needs to be
deleted, the while loop will not be entered.
This can reduce the last redundant `StringBuilder#append ->
StringBuilder#deleteCharAt`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]