tape: Fix capitalization of Uint
This commit is contained in:
parent
134daacc03
commit
717754644c
@ -1,9 +1,6 @@
|
||||
// Package tape implements Table Pair Encoding.
|
||||
package tape
|
||||
|
||||
// TODO: in math/rand: uint is capitalized like Uint, we need to replicate that
|
||||
// here
|
||||
|
||||
import "fmt"
|
||||
|
||||
// encoding and decoding functions must not make any allocations
|
||||
@ -31,8 +28,8 @@ type Int16 interface { ~uint16 | ~int16 }
|
||||
type Int32 interface { ~uint32 | ~int32 }
|
||||
// Int64 is any 64-bit integer.
|
||||
type Int64 interface { ~uint64 | ~int64 }
|
||||
// UInt is any unsigned integer.
|
||||
type UInt interface { ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 }
|
||||
// Uint is any unsigned integer.
|
||||
type Uint interface { ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 }
|
||||
// String is any string.
|
||||
type String interface { ~string | ~[]uint8 }
|
||||
|
||||
@ -110,7 +107,7 @@ func EncodeI64[T Int64](buffer []byte, value T) (n int, err error) {
|
||||
}
|
||||
|
||||
// DecodeGBEU decodes an 8 to 64 bit growing integer into the given buffer.
|
||||
func DecodeGBEU[T UInt](data []byte) (value T, n int, err error) {
|
||||
func DecodeGBEU[T Uint](data []byte) (value T, n int, err error) {
|
||||
var fullValue uint64
|
||||
for _, chunk := range data {
|
||||
fullValue *= 0x80
|
||||
@ -125,7 +122,7 @@ func DecodeGBEU[T UInt](data []byte) (value T, n int, err error) {
|
||||
}
|
||||
|
||||
// EncodeGBEU encodes an 8 to 64 bit growing integer into a given buffer.
|
||||
func EncodeGBEU[T UInt] (buffer []byte, value T) (n int, err error) {
|
||||
func EncodeGBEU[T Uint] (buffer []byte, value T) (n int, err error) {
|
||||
window := (GBEUSize(value) - 1) * 7
|
||||
|
||||
index := 0
|
||||
@ -145,7 +142,7 @@ func EncodeGBEU[T UInt] (buffer []byte, value T) (n int, err error) {
|
||||
}
|
||||
|
||||
// GBEUSize returns the size (in octets) of a GBEU integer.
|
||||
func GBEUSize[T UInt] (value T) int {
|
||||
func GBEUSize[T Uint] (value T) int {
|
||||
length := 0
|
||||
for {
|
||||
value >>= 7
|
||||
|
Loading…
Reference in New Issue
Block a user