You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 10, 2025. It is now read-only.
refactor: improve VarLong and Utf8String handling for better readability and consistency
- Adjusted `VarLong` logic to use clear variable naming (`numBytes` instead of `shift`).
- Replaced bit-shifting expressions with more readable parenthesized forms.
- Refactored `Utf8String` to utilize `VarInt` methods for encoding and decoding operations.
Copy file name to clipboardExpand all lines: surf-cloud-api/surf-cloud-api-common/src/main/kotlin/dev/slne/surf/cloud/api/common/netty/protocol/buffer/types/Utf8String.kt
Copy file name to clipboardExpand all lines: surf-cloud-api/surf-cloud-api-common/src/main/kotlin/dev/slne/surf/cloud/api/common/netty/protocol/buffer/types/VarLong.kt
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ object VarLong {
23
23
*/
24
24
fungetEncodedSize(value:Long): Int {
25
25
for (i in1 until MAX_VARLONG_SIZE) {
26
-
if ((value and-1L shl i *DATA_BITS_PER_BYTE) ==0L) {
26
+
if (value and(-1L shl (i *DATA_BITS_PER_BYTE)) ==0L) {
27
27
return i
28
28
}
29
29
}
@@ -49,16 +49,16 @@ object VarLong {
49
49
*/
50
50
funreadVarLong(buf:ByteBuf): Long {
51
51
var result =0L
52
-
varshift=0
52
+
varnumBytes=0
53
53
54
54
var currentByte:Byte
55
55
do {
56
56
currentByte = buf.readByte()
57
-
result =
58
-
result or((currentByte.toLong() andDATA_BITS_MASK.toLong()) shl (shift++*DATA_BITS_PER_BYTE))
0 commit comments