Skip to content

Commit

Permalink
feat: reduce bound checks in integer decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Mar 21, 2022
1 parent 7787838 commit eb5ab64
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dec_int.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"github.com/go-faster/errors"
)

var intDigits []int8
var intDigits [256]int8

const uint32SafeToMultiply10 = uint32(0xffffffff)/10 - 1
const uint64SafeToMultiple10 = uint64(0xffffffffffffffff)/10 - 1
const (
uint32SafeToMultiply10 = uint32(0xffffffff)/10 - 1
uint64SafeToMultiple10 = uint64(0xffffffffffffffff)/10 - 1
)

func init() {
intDigits = make([]int8, 256)
for i := 0; i < len(intDigits); i++ {
intDigits[i] = invalidCharForNumber
}
Expand Down

0 comments on commit eb5ab64

Please sign in to comment.