Skip to content

Commit 4ddf38e

Browse files
committed
Use Go 1.17 unsafe.Slice().
1 parent 33f6d47 commit 4ddf38e

1 file changed

Lines changed: 1 addition & 13 deletions

File tree

util.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package bitarray
66

77
import (
88
"fmt"
9-
"reflect"
109
"unsafe"
1110
)
1211

@@ -344,18 +343,7 @@ func allocByteSlice(nBytes int) []byte {
344343
}
345344

346345
func asUint64Slice(b []byte) []uint64 {
347-
// s := (*[cap(b)>>3]uint64)(unsafe.Pointer(&b[0]))[:]
348-
349-
n := (len(b) + 7) >> 3
350-
s := make([]uint64, 0)
351-
h := (*reflect.SliceHeader)(unsafe.Pointer(&s))
352-
h.Data, h.Len, h.Cap = uintptr(unsafe.Pointer(&b[0])), n, n
353-
354-
// Since go1.17
355-
// 2021-08-21: golangcilint v1.42.0 does not support go1.17?
356-
// s := unsafe.Slice((*uint64)(unsafe.Pointer(&b[0])), (len(b)+7)>>3)
357-
358-
return s
346+
return unsafe.Slice((*uint64)(unsafe.Pointer(&b[0])), (len(b)+7)>>3)
359347
}
360348

361349
func fill00(b []byte) {

0 commit comments

Comments
 (0)