Bumps [github.com/shamaton/msgpack/v2](https://github.com/shamaton/msgpack) from 2.3.0 to 2.3.1. - [Release notes](https://github.com/shamaton/msgpack/releases) - [Commits](https://github.com/shamaton/msgpack/compare/v2.3.0...v2.3.1) --- updated-dependencies: - dependency-name: github.com/shamaton/msgpack/v2 dependency-version: 2.3.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
41 lines
994 B
Go
41 lines
994 B
Go
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 def.Byte1
|
|
} else if v <= math.MaxUint8 {
|
|
return def.Byte1 + def.Byte1
|
|
} else if v <= math.MaxUint16 {
|
|
return def.Byte1 + def.Byte2
|
|
} else if v <= math.MaxUint32 {
|
|
return def.Byte1 + def.Byte4
|
|
}
|
|
return def.Byte1 + 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
|
|
}
|