Run modernize to rewrite some older go constructs to newer ones

Mostly using slice.Sort, using min/max, slices.Concat, range of int and
fmt.Appendf for byte slices instead of strings.
This commit is contained in:
Mechiel Lukkien
2025-03-06 17:33:06 +01:00
parent f6132bdbc0
commit 64f2f788b1
61 changed files with 146 additions and 232 deletions

View File

@ -70,14 +70,14 @@ func NewBloom(data []byte, k int) (*Bloom, error) {
func (b *Bloom) Add(s string) {
h := hash([]byte(s), b.w)
for i := 0; i < b.k; i++ {
for range b.k {
b.set(h.nextPos())
}
}
func (b *Bloom) Has(s string) bool {
h := hash([]byte(s), b.w)
for i := 0; i < b.k; i++ {
for range b.k {
if !b.has(h.nextPos()) {
return false
}
@ -96,7 +96,7 @@ func (b *Bloom) Modified() bool {
// Ones returns the number of ones.
func (b *Bloom) Ones() (n int) {
for _, d := range b.data {
for i := 0; i < 8; i++ {
for range 8 {
if d&1 != 0 {
n++
}