diff options
author | 2021-09-10 14:42:14 +0200 | |
---|---|---|
committer | 2021-09-10 14:42:14 +0200 | |
commit | f2e5bedea6fb93fbbf68ed8f7153c353cc57a9f0 (patch) | |
tree | 475ae9e7470d0df670ab2a59dce351cd1d07498a /vendor/github.com/goccy/go-json/internal/encoder/int.go | |
parent | fixes + db changes (#204) (diff) | |
download | gotosocial-f2e5bedea6fb93fbbf68ed8f7153c353cc57a9f0.tar.xz |
migrate go version to 1.17 (#203)
* migrate go version to 1.17
* update contributing
Diffstat (limited to 'vendor/github.com/goccy/go-json/internal/encoder/int.go')
-rw-r--r-- | vendor/github.com/goccy/go-json/internal/encoder/int.go | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/vendor/github.com/goccy/go-json/internal/encoder/int.go b/vendor/github.com/goccy/go-json/internal/encoder/int.go index 70ea5f7d7..3a3482d5b 100644 --- a/vendor/github.com/goccy/go-json/internal/encoder/int.go +++ b/vendor/github.com/goccy/go-json/internal/encoder/int.go @@ -49,9 +49,14 @@ var intBELookup = [100]uint16{ var intLookup = [2]*[100]uint16{&intLELookup, &intBELookup} -func AppendInt(out []byte, u64 uint64, code *Opcode) []byte { - n := u64 & code.Mask - negative := (u64>>code.RshiftNum)&1 == 1 +func numMask(numBitSize uint8) uint64 { + return 1<<numBitSize - 1 +} + +func AppendInt(_ *RuntimeContext, out []byte, u64 uint64, code *Opcode) []byte { + mask := numMask(code.NumBitSize) + n := u64 & mask + negative := (u64>>(code.NumBitSize-1))&1 == 1 if !negative { if n < 10 { return append(out, byte(n+'0')) @@ -60,7 +65,7 @@ func AppendInt(out []byte, u64 uint64, code *Opcode) []byte { return append(out, byte(u), byte(u>>8)) } } else { - n = -n & code.Mask + n = -n & mask } lookup := intLookup[endianness] @@ -91,8 +96,9 @@ func AppendInt(out []byte, u64 uint64, code *Opcode) []byte { return append(out, b[i:]...) } -func AppendUint(out []byte, u64 uint64, code *Opcode) []byte { - n := u64 & code.Mask +func AppendUint(_ *RuntimeContext, out []byte, u64 uint64, code *Opcode) []byte { + mask := numMask(code.NumBitSize) + n := u64 & mask if n < 10 { return append(out, byte(n+'0')) } else if n < 100 { |