Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop using rand.Seed() #385

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ttl.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (m *expirationMap[V]) cleanup(store store[V], policy policy[V], onEvict fun
for key, conflict := range keys {
expr := store.Expiration(key)
// Sanity check. Verify that the store agrees that this key is expired.
if store.Expiration(key).After(now) {
if expr.After(now) {
continue
}

Expand Down
4 changes: 1 addition & 3 deletions z/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ func init() {
allocs = make(map[uint64]*Allocator)

// Set up a unique Ref per process.
rand.Seed(time.Now().UnixNano())
allocRef = uint64(rand.Int63n(1<<16)) << 48 //nolint:gosec // cryptographic precision not needed

allocRef = uint64(rand.Int63n(1<<16)) << 48
calculatedLog2 = make([]int, 1025)
for i := 1; i <= 1024; i++ {
calculatedLog2[i] = int(math.Log2(float64(i)))
Expand Down
3 changes: 0 additions & 3 deletions z/buffer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ import (
"math/rand"
"sort"
"testing"
"time"

"github.com/stretchr/testify/require"
)

func TestBuffer(t *testing.T) {
rand.Seed(time.Now().Unix())
const capacity = 512
buffers := newTestBuffers(t, capacity)

Expand Down Expand Up @@ -61,7 +59,6 @@ func TestBuffer(t *testing.T) {
}

func TestBufferWrite(t *testing.T) {
rand.Seed(time.Now().Unix())
const capacity = 32
buffers := newTestBuffers(t, capacity)

Expand Down
Loading