Skip to content

Commit

Permalink
remove reflect usage in is_zero_filled_amd64.go
Browse files Browse the repository at this point in the history
Signed-off-by: Ronald G. Minnich <[email protected]>
  • Loading branch information
rminnich committed Sep 17, 2024
1 parent c36f1e3 commit ea4ae00
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/bytes/is_zero_filled_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@
package bytes

import (
"reflect"
"unsafe"
)

// IsZeroFilled returns true if b consists of zeros only.
func IsZeroFilled(b []byte) bool {
hdr := (*reflect.SliceHeader)((unsafe.Pointer)(&b))
data := unsafe.Pointer(hdr.Data)
length := hdr.Len
length := len(b)
if length == 0 {
return true
}
var data = unsafe.Pointer(&b[0])

if uintptr(data)&0x07 != 0 {
// the data is not aligned, fallback to a simple way
Expand Down

0 comments on commit ea4ae00

Please sign in to comment.