From 49cae59c6abcaa25164c577cb9f1dfdf3d7880ab Mon Sep 17 00:00:00 2001 From: Sahil-4555 Date: Sun, 12 Oct 2025 13:33:02 +0530 Subject: [PATCH] lint fix --- common/bitutil/bitutil.go | 156 +++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/common/bitutil/bitutil.go b/common/bitutil/bitutil.go index d5edd7d9d7..86482bb0c7 100644 --- a/common/bitutil/bitutil.go +++ b/common/bitutil/bitutil.go @@ -27,32 +27,32 @@ func XORBytes(dst, a, b []byte) int { // fastXORBytes xors in bulk. It only works on architectures that support // unaligned read/writes. func fastXORBytes(dst, a, b []byte) int { - n := min(len(a), len(b), len(dst)) - if n == 0 { - return 0 - } - wordSize := int(unsafe.Sizeof(uintptr(0))) - - i := 0 - for ; i < n && uintptr(unsafe.Pointer(&a[i]))%uintptr(wordSize) != 0; i++ { - dst[i] = a[i] ^ b[i] - } - - w := (n - i) / wordSize - if w > 0 { - ad := unsafe.Slice((*uintptr)(unsafe.Pointer(&a[i])), w) - bd := unsafe.Slice((*uintptr)(unsafe.Pointer(&b[i])), w) - dd := unsafe.Slice((*uintptr)(unsafe.Pointer(&dst[i])), w) - for j := 0; j < w; j++ { - dd[j] = ad[j] ^ bd[j] - } - i += w * wordSize - } - - for ; i < n; i++ { - dst[i] = a[i] ^ b[i] - } - return n + n := min(len(a), len(b), len(dst)) + if n == 0 { + return 0 + } + wordSize := int(unsafe.Sizeof(uintptr(0))) + + i := 0 + for ; i < n && uintptr(unsafe.Pointer(&a[i]))%uintptr(wordSize) != 0; i++ { + dst[i] = a[i] ^ b[i] + } + + w := (n - i) / wordSize + if w > 0 { + ad := unsafe.Slice((*uintptr)(unsafe.Pointer(&a[i])), w) + bd := unsafe.Slice((*uintptr)(unsafe.Pointer(&b[i])), w) + dd := unsafe.Slice((*uintptr)(unsafe.Pointer(&dst[i])), w) + for j := 0; j < w; j++ { + dd[j] = ad[j] ^ bd[j] + } + i += w * wordSize + } + + for ; i < n; i++ { + dst[i] = a[i] ^ b[i] + } + return n } // safeXORBytes xors one by one. It works on all architectures, independent if @@ -77,32 +77,32 @@ func ANDBytes(dst, a, b []byte) int { // fastANDBytes ands in bulk. It only works on architectures that support // unaligned read/writes. func fastANDBytes(dst, a, b []byte) int { - n := min(len(a), len(b), len(dst)) - if n == 0 { - return 0 - } - wordSize := int(unsafe.Sizeof(uintptr(0))) - - i := 0 - for ; i < n && uintptr(unsafe.Pointer(&a[i]))%uintptr(wordSize) != 0; i++ { - dst[i] = a[i] & b[i] - } - - w := (n - i) / wordSize - if w > 0 { - ad := unsafe.Slice((*uintptr)(unsafe.Pointer(&a[i])), w) - bd := unsafe.Slice((*uintptr)(unsafe.Pointer(&b[i])), w) - dd := unsafe.Slice((*uintptr)(unsafe.Pointer(&dst[i])), w) - for j := 0; j < w; j++ { - dd[j] = ad[j] & bd[j] - } - i += w * wordSize - } - - for ; i < n; i++ { - dst[i] = a[i] & b[i] - } - return n + n := min(len(a), len(b), len(dst)) + if n == 0 { + return 0 + } + wordSize := int(unsafe.Sizeof(uintptr(0))) + + i := 0 + for ; i < n && uintptr(unsafe.Pointer(&a[i]))%uintptr(wordSize) != 0; i++ { + dst[i] = a[i] & b[i] + } + + w := (n - i) / wordSize + if w > 0 { + ad := unsafe.Slice((*uintptr)(unsafe.Pointer(&a[i])), w) + bd := unsafe.Slice((*uintptr)(unsafe.Pointer(&b[i])), w) + dd := unsafe.Slice((*uintptr)(unsafe.Pointer(&dst[i])), w) + for j := 0; j < w; j++ { + dd[j] = ad[j] & bd[j] + } + i += w * wordSize + } + + for ; i < n; i++ { + dst[i] = a[i] & b[i] + } + return n } // safeANDBytes ands one by one. It works on all architectures, independent if @@ -127,32 +127,32 @@ func ORBytes(dst, a, b []byte) int { // fastORBytes ors in bulk. It only works on architectures that support // unaligned read/writes. func fastORBytes(dst, a, b []byte) int { - n := min(len(a), len(b), len(dst)) - if n == 0 { - return 0 - } - wordSize := int(unsafe.Sizeof(uintptr(0))) - - i := 0 - for ; i < n && uintptr(unsafe.Pointer(&a[i]))%uintptr(wordSize) != 0; i++ { - dst[i] = a[i] | b[i] - } - - w := (n - i) / wordSize - if w > 0 { - ad := unsafe.Slice((*uintptr)(unsafe.Pointer(&a[i])), w) - bd := unsafe.Slice((*uintptr)(unsafe.Pointer(&b[i])), w) - dd := unsafe.Slice((*uintptr)(unsafe.Pointer(&dst[i])), w) - for j := 0; j < w; j++ { - dd[j] = ad[j] | bd[j] - } - i += w * wordSize - } - - for ; i < n; i++ { - dst[i] = a[i] | b[i] - } - return n + n := min(len(a), len(b), len(dst)) + if n == 0 { + return 0 + } + wordSize := int(unsafe.Sizeof(uintptr(0))) + + i := 0 + for ; i < n && uintptr(unsafe.Pointer(&a[i]))%uintptr(wordSize) != 0; i++ { + dst[i] = a[i] | b[i] + } + + w := (n - i) / wordSize + if w > 0 { + ad := unsafe.Slice((*uintptr)(unsafe.Pointer(&a[i])), w) + bd := unsafe.Slice((*uintptr)(unsafe.Pointer(&b[i])), w) + dd := unsafe.Slice((*uintptr)(unsafe.Pointer(&dst[i])), w) + for j := 0; j < w; j++ { + dd[j] = ad[j] | bd[j] + } + i += w * wordSize + } + + for ; i < n; i++ { + dst[i] = a[i] | b[i] + } + return n } // safeORBytes ors one by one. It works on all architectures, independent if