switch to go vendoring

This commit is contained in:
Michael Barz
2023-04-19 20:24:34 +02:00
parent 632fa05ef9
commit afc6ed1e41
8527 changed files with 3004916 additions and 2 deletions
+40
View File
@@ -0,0 +1,40 @@
package encoding
import (
"math"
"github.com/shamaton/msgpack/v2/def"
)
func (e *encoder) calcUint(v uint64) int {
if v <= math.MaxInt8 {
// format code only
return 0
} else if v <= math.MaxUint8 {
return def.Byte1
} else if v <= math.MaxUint16 {
return def.Byte2
} else if v <= math.MaxUint32 {
return def.Byte4
}
return def.Byte8
}
func (e *encoder) writeUint(v uint64, offset int) int {
if v <= math.MaxInt8 {
offset = e.setByte1Uint64(v, offset)
} else if v <= math.MaxUint8 {
offset = e.setByte1Int(def.Uint8, offset)
offset = e.setByte1Uint64(v, offset)
} else if v <= math.MaxUint16 {
offset = e.setByte1Int(def.Uint16, offset)
offset = e.setByte2Uint64(v, offset)
} else if v <= math.MaxUint32 {
offset = e.setByte1Int(def.Uint32, offset)
offset = e.setByte4Uint64(v, offset)
} else {
offset = e.setByte1Int(def.Uint64, offset)
offset = e.setByte8Uint64(v, offset)
}
return offset
}