From e474038f9ea343d439b0c95d3d30b73837f283a5 Mon Sep 17 00:00:00 2001 From: Karl Gaissmaier Date: Sun, 22 Dec 2024 19:37:00 +0100 Subject: [PATCH] simplify --- bitset.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/bitset.go b/bitset.go index 23958ef..ebc7178 100644 --- a/bitset.go +++ b/bitset.go @@ -1418,18 +1418,13 @@ func (b *BitSet) Select(index uint) uint { // top detects the top bit set func (b *BitSet) top() (uint, bool) { - panicIfNull(b) - - idx := len(b.set) - 1 - for ; idx >= 0 && b.set[idx] == 0; idx-- { - } - - // no set bits - if idx < 0 { - return 0, false + for idx := len(b.set) - 1; idx >= 0; idx-- { + if word := b.set[idx]; word != 0 { + return uint(idx<