From ea4ae00d3835c07285b08893272826c5ebb8d0d6 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Tue, 17 Sep 2024 09:18:35 -0700 Subject: [PATCH] remove reflect usage in is_zero_filled_amd64.go Signed-off-by: Ronald G. Minnich --- pkg/bytes/is_zero_filled_amd64.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/bytes/is_zero_filled_amd64.go b/pkg/bytes/is_zero_filled_amd64.go index 4dd96c11..34c69960 100644 --- a/pkg/bytes/is_zero_filled_amd64.go +++ b/pkg/bytes/is_zero_filled_amd64.go @@ -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