@@ -129,11 +129,11 @@ func (b *ByteBuffer) WriteLength(value int) {
129129 if value >= MaxInt32 {
130130 panic (fmt .Errorf ("too long: %d" , value ))
131131 }
132- b .WriteVaruint32 (uint32 (value ))
132+ b .WriteVarUint32 (uint32 (value ))
133133}
134134
135135func (b * ByteBuffer ) ReadLength (err * Error ) int {
136- return int (b .ReadVaruint32 (err ))
136+ return int (b .ReadVarUint32 (err ))
137137}
138138
139139//go:inline
@@ -393,12 +393,12 @@ func (b *ByteBuffer) Reserve(n int) {
393393//go:inline
394394func (b * ByteBuffer ) UnsafeWriteVarint32 (value int32 ) int8 {
395395 u := uint32 ((value << 1 ) ^ (value >> 31 ))
396- return b .UnsafeWriteVaruint32 (u )
396+ return b .UnsafeWriteVarUint32 (u )
397397}
398398
399- // UnsafeWriteVaruint32 writes a varuint32 without grow check.
399+ // UnsafeWriteVarUint32 writes a VarUint32 without grow check.
400400// Caller must have called Reserve(8) beforehand (8 for bulk uint64 write).
401- func (b * ByteBuffer ) UnsafeWriteVaruint32 (value uint32 ) int8 {
401+ func (b * ByteBuffer ) UnsafeWriteVarUint32 (value uint32 ) int8 {
402402 if value >> 7 == 0 {
403403 b .data [b .writerIndex ] = byte (value )
404404 b .writerIndex ++
@@ -600,13 +600,13 @@ func (b *ByteBuffer) UnsafeWriteBool(v bool) {
600600//go:inline
601601func (b * ByteBuffer ) UnsafePutVarInt32 (offset int , value int32 ) int {
602602 u := uint32 ((value << 1 ) ^ (value >> 31 ))
603- return b .UnsafePutVaruint32 (offset , u )
603+ return b .UnsafePutVarUint32 (offset , u )
604604}
605605
606- // UnsafePutVaruint32 writes an unsigned varuint32 at the given offset without advancing writerIndex.
606+ // UnsafePutVarUint32 writes an unsigned VarUint32 at the given offset without advancing writerIndex.
607607// Caller must have called Reserve(8) to ensure capacity (8 for bulk uint64 write).
608608// Returns the number of bytes written (1-5).
609- func (b * ByteBuffer ) UnsafePutVaruint32 (offset int , value uint32 ) int {
609+ func (b * ByteBuffer ) UnsafePutVarUint32 (offset int , value uint32 ) int {
610610 if value >> 7 == 0 {
611611 b .data [offset ] = byte (value )
612612 return 1
@@ -666,13 +666,13 @@ func (b *ByteBuffer) UnsafePutVaruint32(offset int, value uint32) int {
666666//go:inline
667667func (b * ByteBuffer ) UnsafePutVarInt64 (offset int , value int64 ) int {
668668 u := uint64 ((value << 1 ) ^ (value >> 63 ))
669- return b .UnsafePutVaruint64 (offset , u )
669+ return b .UnsafePutVarUint64 (offset , u )
670670}
671671
672- // UnsafePutVaruint64 writes an unsigned varuint64 at the given offset without advancing writerIndex.
672+ // UnsafePutVarUint64 writes an unsigned VarUint64 at the given offset without advancing writerIndex.
673673// Caller must have called Reserve(16) to ensure capacity (for bulk writes).
674674// Returns the number of bytes written (1-9).
675- func (b * ByteBuffer ) UnsafePutVaruint64 (offset int , value uint64 ) int {
675+ func (b * ByteBuffer ) UnsafePutVarUint64 (offset int , value uint64 ) int {
676676 if value >> 7 == 0 {
677677 b .data [offset ] = byte (value )
678678 return 1
@@ -795,13 +795,13 @@ func (b *ByteBuffer) PutInt32(index int, value int32) {
795795 binary .LittleEndian .PutUint32 (b .data [index :], uint32 (value ))
796796}
797797
798- // WriteVaruint32 writes a 1-5 byte positive int (no zigzag encoding), returns the number of bytes written.
798+ // WriteVarUint32 writes a 1-5 byte positive int (no zigzag encoding), returns the number of bytes written.
799799// Use this for lengths, type IDs, and other non-negative values.
800800//
801801//go:inline
802- func (b * ByteBuffer ) WriteVaruint32 (value uint32 ) int8 {
802+ func (b * ByteBuffer ) WriteVarUint32 (value uint32 ) int8 {
803803 b .grow (8 ) // 8 bytes for bulk uint64 write in worst case
804- return b .UnsafeWriteVaruint32 (value )
804+ return b .UnsafeWriteVarUint32 (value )
805805}
806806
807807type BufferObject interface {
@@ -815,11 +815,11 @@ type BufferObject interface {
815815//go:inline
816816func (b * ByteBuffer ) WriteVarint64 (value int64 ) {
817817 u := uint64 ((value << 1 ) ^ (value >> 63 ))
818- b .WriteVaruint64 (u )
818+ b .WriteVarUint64 (u )
819819}
820820
821- // WriteVaruint64 writes to unsigned varint (up to 9 bytes)
822- func (b * ByteBuffer ) WriteVaruint64 (value uint64 ) {
821+ // WriteVarUint64 writes to unsigned varint (up to 9 bytes)
822+ func (b * ByteBuffer ) WriteVarUint64 (value uint64 ) {
823823 b .grow (9 )
824824 offset := b .writerIndex
825825 data := b .data [offset : offset + 9 ]
@@ -942,7 +942,7 @@ func (b *ByteBuffer) readVaruint36SmallSlow(err *Error) uint64 {
942942//
943943//go:inline
944944func (b * ByteBuffer ) ReadVarint64 (err * Error ) int64 {
945- u := b .ReadVaruint64 (err )
945+ u := b .ReadVarUint64 (err )
946946 v := int64 (u >> 1 )
947947 if u & 1 != 0 {
948948 v = ^ v
@@ -1053,20 +1053,20 @@ func (b *ByteBuffer) ReadTaggedUint64(err *Error) uint64 {
10531053 return value
10541054}
10551055
1056- // ReadVaruint64 reads unsigned varint
1056+ // ReadVarUint64 reads unsigned varint
10571057//
10581058//go:inline
1059- func (b * ByteBuffer ) ReadVaruint64 (err * Error ) uint64 {
1059+ func (b * ByteBuffer ) ReadVarUint64 (err * Error ) uint64 {
10601060 if b .remaining () >= 9 {
1061- return b .readVaruint64Fast ()
1061+ return b .readVarUint64Fast ()
10621062 }
1063- return b .readVaruint64Slow (err )
1063+ return b .readVarUint64Slow (err )
10641064}
10651065
10661066// Fast path (when the remaining bytes are sufficient)
10671067//
10681068//go:inline
1069- func (b * ByteBuffer ) readVaruint64Fast () uint64 {
1069+ func (b * ByteBuffer ) readVarUint64Fast () uint64 {
10701070 // Single instruction load using unsafe pointer cast (little-endian only)
10711071 var bulk uint64
10721072 if isLittleEndian {
@@ -1117,7 +1117,7 @@ func (b *ByteBuffer) readVaruint64Fast() uint64 {
11171117}
11181118
11191119// Slow path (read byte by byte)
1120- func (b * ByteBuffer ) readVaruint64Slow (err * Error ) uint64 {
1120+ func (b * ByteBuffer ) readVarUint64Slow (err * Error ) uint64 {
11211121 var result uint64
11221122 var shift uint
11231123 for i := 0 ; i < 8 ; i ++ {
@@ -1167,14 +1167,14 @@ func (b *ByteBuffer) ReadUint8(err *Error) uint8 {
11671167//go:inline
11681168func (b * ByteBuffer ) WriteVarint32 (value int32 ) int8 {
11691169 u := uint32 ((value << 1 ) ^ (value >> 31 ))
1170- return b .WriteVaruint32 (u )
1170+ return b .WriteVarUint32 (u )
11711171}
11721172
11731173// ReadVarint32 reads a signed int32 using zigzag decoding (compatible with Java's readVarint32).
11741174//
11751175//go:inline
11761176func (b * ByteBuffer ) ReadVarint32 (err * Error ) int32 {
1177- u := b .ReadVaruint32 (err )
1177+ u := b .ReadVarUint32 (err )
11781178 v := int32 (u >> 1 )
11791179 if u & 1 != 0 {
11801180 v = ^ v
@@ -1187,7 +1187,7 @@ func (b *ByteBuffer) ReadVarint32(err *Error) int32 {
11871187//
11881188//go:inline
11891189func (b * ByteBuffer ) UnsafeReadVarint32 () int32 {
1190- u := b .readVaruint32Fast ()
1190+ u := b .readVarUint32Fast ()
11911191 v := int32 (u >> 1 )
11921192 if u & 1 != 0 {
11931193 v = ^ v
@@ -1200,44 +1200,44 @@ func (b *ByteBuffer) UnsafeReadVarint32() int32 {
12001200//
12011201//go:inline
12021202func (b * ByteBuffer ) UnsafeReadVarint64 () int64 {
1203- u := b .readVaruint64Fast ()
1203+ u := b .readVarUint64Fast ()
12041204 v := int64 (u >> 1 )
12051205 if u & 1 != 0 {
12061206 v = ^ v
12071207 }
12081208 return v
12091209}
12101210
1211- // UnsafeReadVaruint32 reads a varuint32 without bounds checking.
1211+ // UnsafeReadVarUint32 reads a VarUint32 without bounds checking.
12121212// Caller must ensure remaining() >= 5 before calling.
12131213//
12141214//go:inline
1215- func (b * ByteBuffer ) UnsafeReadVaruint32 () uint32 {
1216- return b .readVaruint32Fast ()
1215+ func (b * ByteBuffer ) UnsafeReadVarUint32 () uint32 {
1216+ return b .readVarUint32Fast ()
12171217}
12181218
1219- // UnsafeReadVaruint64 reads a varuint64 without bounds checking.
1219+ // UnsafeReadVarUint64 reads a VarUint64 without bounds checking.
12201220// Caller must ensure remaining() >= 10 before calling.
12211221//
12221222//go:inline
1223- func (b * ByteBuffer ) UnsafeReadVaruint64 () uint64 {
1224- return b .readVaruint64Fast ()
1223+ func (b * ByteBuffer ) UnsafeReadVarUint64 () uint64 {
1224+ return b .readVarUint64Fast ()
12251225}
12261226
1227- // ReadVaruint32 reads a varuint32 and sets error on bounds violation
1227+ // ReadVarUint32 reads a VarUint32 and sets error on bounds violation
12281228//
12291229//go:inline
1230- func (b * ByteBuffer ) ReadVaruint32 (err * Error ) uint32 {
1230+ func (b * ByteBuffer ) ReadVarUint32 (err * Error ) uint32 {
12311231 if b .remaining () >= 8 { // Need 8 bytes for bulk uint64 read in fast path
1232- return b .readVaruint32Fast ()
1232+ return b .readVarUint32Fast ()
12331233 }
1234- return b .readVaruint32Slow (err )
1234+ return b .readVarUint32Slow (err )
12351235}
12361236
12371237// Fast path reading (when the remaining bytes are sufficient)
12381238//
12391239//go:inline
1240- func (b * ByteBuffer ) readVaruint32Fast () uint32 {
1240+ func (b * ByteBuffer ) readVarUint32Fast () uint32 {
12411241 // Single instruction load using unsafe pointer cast (little-endian only)
12421242 // On big-endian systems, use binary.LittleEndian which the compiler optimizes
12431243 var bulk uint64
@@ -1271,7 +1271,7 @@ func (b *ByteBuffer) readVaruint32Fast() uint32 {
12711271}
12721272
12731273// Slow path reading (processing byte by byte)
1274- func (b * ByteBuffer ) readVaruint32Slow (err * Error ) uint32 {
1274+ func (b * ByteBuffer ) readVarUint32Slow (err * Error ) uint32 {
12751275 var result uint32
12761276 var shift uint
12771277 for {
@@ -1287,7 +1287,7 @@ func (b *ByteBuffer) readVaruint32Slow(err *Error) uint32 {
12871287 }
12881288 shift += 7
12891289 if shift >= 35 {
1290- * err = DeserializationError ("varuint32 overflow" )
1290+ * err = DeserializationError ("VarUint32 overflow" )
12911291 return 0
12921292 }
12931293 }
@@ -1299,18 +1299,18 @@ func (b *ByteBuffer) PutUint8(writerIndex int, value uint8) {
12991299 b .data [writerIndex ] = byte (value )
13001300}
13011301
1302- // WriteVaruint32Small7 writes a uint32 in variable-length small-7 format
1303- func (b * ByteBuffer ) WriteVaruint32Small7 (value uint32 ) int {
1302+ // WriteVarUint32Small7 writes a uint32 in variable-length small-7 format
1303+ func (b * ByteBuffer ) WriteVarUint32Small7 (value uint32 ) int {
13041304 b .grow (8 )
13051305 if value >> 7 == 0 {
13061306 b .data [b .writerIndex ] = byte (value )
13071307 b .writerIndex ++
13081308 return 1
13091309 }
1310- return b .continueWriteVaruint32Small7 (value )
1310+ return b .continueWriteVarUint32Small7 (value )
13111311}
13121312
1313- func (b * ByteBuffer ) continueWriteVaruint32Small7 (value uint32 ) int {
1313+ func (b * ByteBuffer ) continueWriteVarUint32Small7 (value uint32 ) int {
13141314 encoded := uint64 (value & 0x7F )
13151315 encoded |= uint64 ((value & 0x3f80 )<< 1 ) | 0x80
13161316 idx := b .writerIndex
@@ -1434,8 +1434,8 @@ func (b *ByteBuffer) UnsafePutTaggedUint64(offset int, value uint64) int {
14341434 return 9
14351435}
14361436
1437- // ReadVaruint32Small7 reads a varuint32 in small-7 format with error checking
1438- func (b * ByteBuffer ) ReadVaruint32Small7 (err * Error ) uint32 {
1437+ // ReadVarUint32Small7 reads a VarUint32 in small-7 format with error checking
1438+ func (b * ByteBuffer ) ReadVarUint32Small7 (err * Error ) uint32 {
14391439 if b .readerIndex >= len (b .data ) {
14401440 * err = BufferOutOfBoundError (b .readerIndex , 1 , len (b .data ))
14411441 return 0
@@ -1447,10 +1447,10 @@ func (b *ByteBuffer) ReadVaruint32Small7(err *Error) uint32 {
14471447 b .readerIndex = readIdx
14481448 return uint32 (v )
14491449 }
1450- return b .readVaruint32Small14 (err )
1450+ return b .readVarUint32Small14 (err )
14511451}
14521452
1453- func (b * ByteBuffer ) readVaruint32Small14 (err * Error ) uint32 {
1453+ func (b * ByteBuffer ) readVarUint32Small14 (err * Error ) uint32 {
14541454 readIdx := b .readerIndex
14551455 if len (b .data )- readIdx >= 5 {
14561456 four := binary .LittleEndian .Uint32 (b .data [readIdx :])
@@ -1460,7 +1460,7 @@ func (b *ByteBuffer) readVaruint32Small14(err *Error) uint32 {
14601460 readIdx ++
14611461 value |= (four >> 1 ) & 0x3f80
14621462 if four & 0x8000 != 0 {
1463- return b .continueReadVaruint32 (readIdx , four , value )
1463+ return b .continueReadVarUint32 (readIdx , four , value )
14641464 }
14651465 }
14661466 b .readerIndex = readIdx
@@ -1469,7 +1469,7 @@ func (b *ByteBuffer) readVaruint32Small14(err *Error) uint32 {
14691469 return uint32 (b .readVaruint36Slow (err ))
14701470}
14711471
1472- func (b * ByteBuffer ) continueReadVaruint32 (readIdx int , bulkRead , value uint32 ) uint32 {
1472+ func (b * ByteBuffer ) continueReadVarUint32 (readIdx int , bulkRead , value uint32 ) uint32 {
14731473 readIdx ++
14741474 value |= (bulkRead >> 2 ) & 0x1fc000
14751475 if bulkRead & 0x800000 != 0 {
0 commit comments