Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions internal/strategies/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"math/rand/v2"
"os"
"strconv"
"sync"
"time"

"github.com/twmb/murmur3"
)
Expand Down Expand Up @@ -63,29 +61,20 @@
return ""
}

type rng struct {
sync.Mutex
random *rand.Rand
}
type rng struct{}

func (r *rng) int() int {
r.Lock()
defer r.Unlock()
return r.random.IntN(100) + 1
return rand.IntN(100) + 1
}

func (r *rng) float() float64 {
return float64(r.int())
}

func (r *rng) string() string {
r.Lock()
defer r.Unlock()
return strconv.Itoa(r.random.IntN(10000) + 1)
return strconv.Itoa(rand.IntN(10000) + 1)
}

// newRng creates a new random number generator and uses a mutex
// internally to ensure safe concurrent reads.
func newRng() *rng {
return &rng{random: rand.New(rand.NewPCG(uint64(time.Now().UnixNano()), uint64(os.Getpid())))}
return &rng{}
}
Loading