diff --git a/pkg/encoding/simple8b/encoding.go b/pkg/encoding/simple8b/encoding.go index 8eaab0a0cf..f029df217c 100644 --- a/pkg/encoding/simple8b/encoding.go +++ b/pkg/encoding/simple8b/encoding.go @@ -468,6 +468,8 @@ func Decode(dst *[240]uint64, v uint64) (n int, err error) { // Decode writes the uncompressed values from src to dst. It returns the number // of values written or an error. +//go:nocheckptr +// nocheckptr while the underlying struct layout doesn't change func DecodeAll(dst, src []uint64) (value int, err error) { j := 0 for _, v := range src { @@ -480,6 +482,8 @@ func DecodeAll(dst, src []uint64) (value int, err error) { // DecodeBytesBigEndian writes the compressed, big-endian values from src to dst. It returns the number // of values written or an error. +//go:nocheckptr +// nocheckptr while the underlying struct layout doesn't change func DecodeBytesBigEndian(dst []uint64, src []byte) (value int, err error) { if len(src)&7 != 0 { return 0, errors.New("src length is not multiple of 8") @@ -503,11 +507,6 @@ func canPack(src []uint64, n, bits int) bool { return false } - end := len(src) - if n < end { - end = n - } - // Selector 0,1 are special and use 0 bits to encode runs of 1's if bits == 0 { for _, v := range src { @@ -520,8 +519,8 @@ func canPack(src []uint64, n, bits int) bool { max := uint64((1 << uint64(bits)) - 1) - for i := 0; i < end; i++ { - if src[i] > max { + for _, s := range src[:n] { + if s > max { return false } } @@ -541,6 +540,7 @@ func pack120(src []uint64) uint64 { // pack60 packs 60 values from in using 1 bit each func pack60(src []uint64) uint64 { + _ = src[59] // eliminate multiple bounds checks return 2<<60 | src[0] | src[1]<<1 | @@ -607,6 +607,7 @@ func pack60(src []uint64) uint64 { // pack30 packs 30 values from in using 2 bits each func pack30(src []uint64) uint64 { + _ = src[29] // eliminate multiple bounds checks return 3<<60 | src[0] | src[1]<<2 | @@ -642,6 +643,7 @@ func pack30(src []uint64) uint64 { // pack20 packs 20 values from in using 3 bits each func pack20(src []uint64) uint64 { + _ = src[19] // eliminate multiple bounds checks return 4<<60 | src[0] | src[1]<<3 | @@ -667,6 +669,7 @@ func pack20(src []uint64) uint64 { // pack15 packs 15 values from in using 3 bits each func pack15(src []uint64) uint64 { + _ = src[14] // eliminate multiple bounds checks return 5<<60 | src[0] | src[1]<<4 | @@ -687,6 +690,7 @@ func pack15(src []uint64) uint64 { // pack12 packs 12 values from in using 5 bits each func pack12(src []uint64) uint64 { + _ = src[11] // eliminate multiple bounds checks return 6<<60 | src[0] | src[1]<<5 | @@ -704,6 +708,7 @@ func pack12(src []uint64) uint64 { // pack10 packs 10 values from in using 6 bits each func pack10(src []uint64) uint64 { + _ = src[9] // eliminate multiple bounds checks return 7<<60 | src[0] | src[1]<<6 | @@ -719,6 +724,7 @@ func pack10(src []uint64) uint64 { // pack8 packs 8 values from in using 7 bits each func pack8(src []uint64) uint64 { + _ = src[7] // eliminate multiple bounds checks return 8<<60 | src[0] | src[1]<<7 | @@ -732,6 +738,7 @@ func pack8(src []uint64) uint64 { // pack7 packs 7 values from in using 8 bits each func pack7(src []uint64) uint64 { + _ = src[6] // eliminate multiple bounds checks return 9<<60 | src[0] | src[1]<<8 | @@ -744,6 +751,7 @@ func pack7(src []uint64) uint64 { // pack6 packs 6 values from in using 10 bits each func pack6(src []uint64) uint64 { + _ = src[5] // eliminate multiple bounds checks return 10<<60 | src[0] | src[1]<<10 | @@ -755,6 +763,7 @@ func pack6(src []uint64) uint64 { // pack5 packs 5 values from in using 12 bits each func pack5(src []uint64) uint64 { + _ = src[4] // eliminate multiple bounds checks return 11<<60 | src[0] | src[1]<<12 | @@ -765,6 +774,7 @@ func pack5(src []uint64) uint64 { // pack4 packs 4 values from in using 15 bits each func pack4(src []uint64) uint64 { + _ = src[3] // eliminate multiple bounds checks return 12<<60 | src[0] | src[1]<<15 | @@ -774,6 +784,7 @@ func pack4(src []uint64) uint64 { // pack3 packs 3 values from in using 20 bits each func pack3(src []uint64) uint64 { + _ = src[2] // eliminate multiple bounds checks return 13<<60 | src[0] | src[1]<<20 | @@ -782,6 +793,7 @@ func pack3(src []uint64) uint64 { // pack2 packs 2 values from in using 30 bits each func pack2(src []uint64) uint64 { + _ = src[1] // eliminate multiple bounds checks return 14<<60 | src[0] | src[1]<<30