diff --git a/go/cache/theine/sketch_test.go b/go/cache/theine/sketch_test.go index 3437f0cac3c..fb53fa8e5fb 100644 --- a/go/cache/theine/sketch_test.go +++ b/go/cache/theine/sketch_test.go @@ -23,7 +23,7 @@ func TestSketch(t *testing.T) { sketch.SampleSize = 5120 failed := 0 - for i := 0; i < 500; i++ { + for i := range 500 { key := fmt.Sprintf("key:%d", i) keyh := xxhash.Sum64String(key) sketch.Add(keyh) diff --git a/go/cache/theine/store.go b/go/cache/theine/store.go index 21ce084e8a5..cef5a89c8b7 100644 --- a/go/cache/theine/store.go +++ b/go/cache/theine/store.go @@ -208,7 +208,7 @@ func NewStore[K cachekey, V cacheval](maxsize int64, doorkeeper bool) *Store[K, writebufsize: writeBufSize, } s.shards = make([]*Shard[K, V], 0, s.shardCount) - for i := 0; i < int(s.shardCount); i++ { + for range s.shardCount { s.shards = append(s.shards, NewShard[K, V](uint(dequeSize), doorkeeper)) } diff --git a/go/cache/theine/store_test.go b/go/cache/theine/store_test.go index 9f337b818ad..e6a2f9d5679 100644 --- a/go/cache/theine/store_test.go +++ b/go/cache/theine/store_test.go @@ -52,7 +52,7 @@ func TestProcessDeque(t *testing.T) { shard := store.shards[index] shard.qsize = 10 - for i := keyint(0); i < 5; i++ { + for i := range keyint(5) { entry := &Entry[keyint, cachedint]{key: i} entry.cost.Store(1) store.shards[index].deque.PushFront(entry) @@ -75,7 +75,7 @@ func TestDoorKeeperDynamicSize(t *testing.T) { store := NewStore[keyint, cachedint](200000, true) shard := store.shards[0] require.True(t, shard.doorkeeper.Capacity == 512) - for i := keyint(0); i < 5000; i++ { + for i := range keyint(5000) { shard.set(i, &Entry[keyint, cachedint]{}) } require.True(t, shard.doorkeeper.Capacity > 100000) diff --git a/go/cache/theine/tlfu_test.go b/go/cache/theine/tlfu_test.go index ac6ddaabdb6..f798f89549f 100644 --- a/go/cache/theine/tlfu_test.go +++ b/go/cache/theine/tlfu_test.go @@ -33,7 +33,7 @@ func TestTlfu(t *testing.T) { require.Equal(t, 0, tlfu.slru.protected.len) var entries []*Entry[StringKey, string] - for i := 0; i < 200; i++ { + for i := range 200 { e := NewEntry(StringKey(fmt.Sprintf("%d", i)), "", 1) evicted := tlfu.Set(e) entries = append(entries, e) @@ -78,7 +78,7 @@ func TestTlfu(t *testing.T) { require.Equal(t, 998, tlfu.slru.probation.len) var entries2 []*Entry[StringKey, string] - for i := 0; i < 1000; i++ { + for i := range 1000 { e := NewEntry(StringKey(fmt.Sprintf("%d*", i)), "", 1) tlfu.Set(e) entries2 = append(entries2, e) @@ -103,7 +103,7 @@ func TestEvictEntries(t *testing.T) { require.Equal(t, 0, tlfu.slru.probation.len) require.Equal(t, 0, tlfu.slru.protected.len) - for i := 0; i < 500; i++ { + for i := range 500 { tlfu.Set(NewEntry(StringKey(fmt.Sprintf("%d:1", i)), "", 1)) } require.Equal(t, 500, tlfu.slru.probation.len)