@@ -525,8 +525,11 @@ func (b *BitSet) DeleteAt(i uint) *BitSet {
525
525
//
526
526
// See also [BitSet.AsSlice] and [BitSet.NextSetMany].
527
527
func (b * BitSet ) AppendTo (buf []uint ) []uint {
528
+ // In theory, we could overflow uint, but in practice, we will not.
528
529
for idx , word := range b .set {
529
530
for word != 0 {
531
+ // In theory idx<<log2WordSize could overflow, but it will not overflow
532
+ // in practice.
530
533
buf = append (buf , uint (idx << log2WordSize + bits .TrailingZeros64 (word )))
531
534
532
535
// clear the rightmost set bit
@@ -548,6 +551,8 @@ func (b *BitSet) AsSlice(buf []uint) []uint {
548
551
for idx , word := range b .set {
549
552
for ; word != 0 ; size ++ {
550
553
// panics if capacity of buf is exceeded.
554
+ // In theory idx<<log2WordSize could overflow, but it will not overflow
555
+ // in practice.
551
556
buf [size ] = uint (idx << log2WordSize + bits .TrailingZeros64 (word ))
552
557
553
558
// clear the rightmost set bit
@@ -615,6 +620,7 @@ func (b *BitSet) NextSet(i uint) (uint, bool) {
615
620
// However if Count() is large, it might be preferable to
616
621
// use several calls to NextSetMany for memory reasons.
617
622
func (b * BitSet ) NextSetMany (i uint , buffer []uint ) (uint , []uint ) {
623
+ // In theory, we could overflow uint, but in practice, we will not.
618
624
capacity := cap (buffer )
619
625
result := buffer [:capacity ]
620
626
0 commit comments