Skip to content

Commit

Permalink
math.MaxInt was added in Go 1.17, so don't use it.
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed Sep 23, 2021
1 parent 1891d01 commit e0af6a2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ func (enc *Encoder) eMap(key Key, rv reflect.Value, inline bool) {
}
}

const is32Bit = (32 << (^uint(0) >> 63)) == 32

func (enc *Encoder) eStruct(key Key, rv reflect.Value, inline bool) {
// Write keys for fields directly under this key first, because if we write
// a field that creates a new table then all keys under it will be in that
Expand Down Expand Up @@ -415,7 +417,7 @@ func (enc *Encoder) eStruct(key Key, rv reflect.Value, inline bool) {
// is needed. See #314, and https://www.reddit.com/r/golang/comments/pnx8v4
// This also works fine on 64bit, but 32bit archs are somewhat
// rare and this is a wee bit faster.
if math.MaxInt == math.MaxInt32 {
if is32Bit {
copyStart := make([]int, len(start))
copy(copyStart, start)
fieldsDirect = append(fieldsDirect, append(copyStart, f.Index...))
Expand Down

0 comments on commit e0af6a2

Please sign in to comment.