Skip to content

Commit

Permalink
*: Simplify for loop over integer range
Browse files Browse the repository at this point in the history
Fix `intrange` linter remarks. Refs #552.

Signed-off-by: Leonard Lyubich <leonard@morphbits.io>
  • Loading branch information
cthulhu-rider committed Jan 9, 2025
1 parent 39c88ac commit d5b0d83
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion client/object_replicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func BenchmarkPrepareReplicationMessage(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
_, err = prepareReplicateMessage(id, bytes.NewReader(bObj), signer, true)
require.NoError(b, err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/proto/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func benchmarkType[T anySupportedType](
buf := make([]byte, sizeFunc(fieldNum, v))
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
marshalFunc(buf, fieldNum, v)
}
}
Expand All @@ -233,7 +233,7 @@ func benchmarkRepeatedType[T anySupportedType](

b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
marshalFunc(buf, fieldNum, v)
}
}
Expand Down Expand Up @@ -389,7 +389,7 @@ func BenchmarkMarshalEmbedded(b *testing.B) {

b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
proto.MarshalToEmbedded(buf, fieldNum, v)
}
}
Expand Down
4 changes: 2 additions & 2 deletions netmap/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func BenchmarkPlacementPolicyInteropability(b *testing.B) {

b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
b.StartTimer()
v, err := nm.ContainerNodes(tt.Policy, pivot)
b.StopTimer()
Expand Down Expand Up @@ -184,7 +184,7 @@ func BenchmarkManySelects(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()

for i := 0; i < b.N; i++ {
for range b.N {
_, err = nm.ContainerNodes(tt.Policy, pivot)
if err != nil {
b.FailNow()
Expand Down
6 changes: 3 additions & 3 deletions netmap/selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func BenchmarkHRWSort(b *testing.B) {
b.Run("sort by value, no weight", func(b *testing.B) {
realNodes := make([]nodes, netmapSize)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
b.StopTimer()
copy(realNodes, vectors)
b.StartTimer()
Expand All @@ -52,7 +52,7 @@ func BenchmarkHRWSort(b *testing.B) {
b.Run("sort by value", func(b *testing.B) {
realNodes := make([]nodes, netmapSize)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
b.StopTimer()
copy(realNodes, vectors)
b.StartTimer()
Expand Down Expand Up @@ -99,7 +99,7 @@ func BenchmarkPolicyHRWType(b *testing.B) {
nm.SetNodes(nodes)

b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
_, err := nm.ContainerNodes(p, cid.ID{1})
if err != nil {
b.Fatal()
Expand Down
16 changes: 8 additions & 8 deletions object/slicer/slicer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func benchmarkSliceDataIntoObjects(b *testing.B, size, sizeLimit uint64) {
b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
_, err = s.Put(ctx, r, in.attributes)
b.StopTimer()
require.NoError(b, err)
Expand All @@ -115,7 +115,7 @@ func benchmarkSliceDataIntoObjects(b *testing.B, size, sizeLimit uint64) {
var err error
var w *slicer.PayloadWriter

for i := 0; i < b.N; i++ {
for range b.N {
w, err = s.InitPut(ctx, in.attributes)
b.StopTimer()
require.NoError(b, err)
Expand Down Expand Up @@ -954,7 +954,7 @@ func BenchmarkWritePayloadBuffer(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
w, err := slicer.InitPut(ctx, discardObject{opts: opts}, hdr, in.signer, opts)
require.NoError(b, err)

Expand All @@ -970,7 +970,7 @@ func BenchmarkWritePayloadBuffer(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
w, err := slicer.InitPut(ctx, discardObject{opts: opts}, hdr, in.signer, opts)
require.NoError(b, err)

Expand Down Expand Up @@ -1009,7 +1009,7 @@ func BenchmarkReadPayloadBuffer(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
_, err := slicer.Put(ctx, discardObject{opts: opts}, hdr, in.signer, bytes.NewReader(in.payload), opts)
require.NoError(b, err)
}
Expand All @@ -1019,7 +1019,7 @@ func BenchmarkReadPayloadBuffer(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
_, err := slicer.Put(ctx, discardObject{opts: opts}, hdr, in.signer, bytes.NewReader(in.payload), opts)
require.NoError(b, err)
}
Expand Down Expand Up @@ -1177,7 +1177,7 @@ func BenchmarkKnownPayloadSize(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
_, err := slicer.Put(ctx, discardObject{opts: opts}, hdr, signer, bytes.NewReader(payload), opts)
require.NoError(b, err)
}
Expand All @@ -1198,7 +1198,7 @@ func BenchmarkKnownPayloadSize(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()

for i := 0; i < b.N; i++ {
for range b.N {
w, err := slicer.InitPut(ctx, discardObject{opts: opts}, hdr, signer, opts)
require.NoError(b, err)

Expand Down

0 comments on commit d5b0d83

Please sign in to comment.