From a512614d907094b779eec329c8f8054cd511a302 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Mon, 9 Dec 2024 13:59:07 -0500 Subject: [PATCH] bad merge fix --- bitset.go | 10 +++++----- bitset_test.go | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bitset.go b/bitset.go index 16cc781..8a9844e 100644 --- a/bitset.go +++ b/bitset.go @@ -1462,7 +1462,7 @@ func (b *BitSet) OnesBetween(from, to uint) uint { if startWord == endWord { // Create mask for bits between from and to mask := uint64((1<= startOffset - count = uint(popcount(b.set[startWord] & startMask)) + count = uint(bits.OnesCount64(b.set[startWord] & startMask)) // 2b: Count all bits in complete words between start and end if endWord > startWord+1 { @@ -1480,7 +1480,7 @@ func (b *BitSet) OnesBetween(from, to uint) uint { // 2c: Count bits in last word (from start of word to endOffset) if endOffset > 0 { endMask := uint64(1<> log2WordSize @@ -1600,7 +1600,7 @@ func (b *BitSet) DepositTo(mask *BitSet, dst *BitSet) { // Deposit bits according to mask dst.set[i] = (dst.set[i] &^ mask.set[i]) | pdep(sourceBits, mask.set[i]) - inPos += uint(popcount(mask.set[i])) + inPos += uint(bits.OnesCount64(mask.set[i])) } } diff --git a/bitset_test.go b/bitset_test.go index 926ab62..bee2999 100644 --- a/bitset_test.go +++ b/bitset_test.go @@ -17,6 +17,7 @@ import ( "fmt" "io" "math" + "math/bits" "math/rand" "strconv" "testing" @@ -2390,7 +2391,7 @@ func TestPext(t *testing.T) { w := rng.Uint64() m := rng.Uint64() result := pext(w, m) - popCount := popcount(m) + popCount := bits.OnesCount64(m) // Test invariants if popCount > 0 && result >= (uint64(1)< popcount(w&m) { + if bits.OnesCount64(result) > bits.OnesCount64(w&m) { t.Fatalf("Case %d: result has more 1s than masked input: result=%x, input&mask=%x", i, result, w&m) } @@ -2435,7 +2436,7 @@ func TestPdep(t *testing.T) { w := rng.Uint64() // value to deposit m := rng.Uint64() // mask result := pdep(w, m) - popCount := popcount(m) + popCount := bits.OnesCount64(m) // Test invariants if result&^m != 0 { @@ -2443,7 +2444,7 @@ func TestPdep(t *testing.T) { i, result, m) } - if popcount(result) > popcount(w) { + if bits.OnesCount64(result) > bits.OnesCount64(w) { t.Fatalf("Case %d: result has more 1s than input: result=%x, input=%x", i, result, w) }