[#1317] go.mod: Use range over int

Since Go 1.22 a "for" statement with a "range" clause is able
to iterate through integer values from zero to an upper limit.

gopatch script:
@@
var i, e expression
@@
-for i := 0; i <= e - 1; i++ {
+for i := range e {
    ...
}

@@
var i, e expression
@@
-for i := 0; i <= e; i++ {
+for i := range e + 1 {
    ...
}

@@
var i, e expression
@@
-for i := 0; i < e; i++ {
+for i := range e {
    ...
}

Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
Ekaterina Lebedeva 2024-08-30 19:20:55 +03:00
parent 2b3fc50681
commit a685fcdc96
66 changed files with 135 additions and 135 deletions

View file

@ -34,7 +34,7 @@ func TestBlobovniczaTree_Concurrency(t *testing.T) {
var cnt atomic.Int64
var wg sync.WaitGroup
for i := 0; i < 1000; i++ {
for range 1000 {
wg.Add(1)
go func() {
defer wg.Done()

View file

@ -127,7 +127,7 @@ func testBlobovniczaTreeRebuildHelper(t *testing.T, sourceDepth, sourceWidth, ta
eg, egCtx := errgroup.WithContext(context.Background())
storageIDs := make(map[oid.Address][]byte)
storageIDsGuard := &sync.Mutex{}
for i := 0; i < 100; i++ {
for range 100 {
eg.Go(func() error {
obj := blobstortest.NewObject(1024)
data, err := obj.Marshal()

View file

@ -60,7 +60,7 @@ func TestCompression(t *testing.T) {
bigObj := make([]*objectSDK.Object, objCount)
smallObj := make([]*objectSDK.Object, objCount)
for i := 0; i < objCount; i++ {
for i := range objCount {
bigObj[i] = testObject(smallSizeLimit * 2)
smallObj[i] = testObject(smallSizeLimit / 2)
}
@ -219,7 +219,7 @@ func TestConcurrentPut(t *testing.T) {
bigObj := testObject(smallSizeLimit * 2)
var wg sync.WaitGroup
for i := 0; i < concurrentPutCount; i++ {
for range concurrentPutCount {
wg.Add(1)
go func() {
testPut(t, blobStor, bigObj)
@ -235,7 +235,7 @@ func TestConcurrentPut(t *testing.T) {
bigObj := testObject(smallSizeLimit * 2)
var wg sync.WaitGroup
for i := 0; i < concurrentPutCount+1; i++ {
for range concurrentPutCount + 1 {
wg.Add(1)
go func() {
testPutFileExistsError(t, blobStor, bigObj)
@ -251,7 +251,7 @@ func TestConcurrentPut(t *testing.T) {
smallObj := testObject(smallSizeLimit / 2)
var wg sync.WaitGroup
for i := 0; i < concurrentPutCount; i++ {
for range concurrentPutCount {
wg.Add(1)
go func() {
testPut(t, blobStor, smallObj)
@ -302,7 +302,7 @@ func TestConcurrentDelete(t *testing.T) {
testPut(t, blobStor, bigObj)
var wg sync.WaitGroup
for i := 0; i < 2; i++ {
for range 2 {
wg.Add(1)
go func() {
testDelete(t, blobStor, bigObj)
@ -319,7 +319,7 @@ func TestConcurrentDelete(t *testing.T) {
testPut(t, blobStor, smallObj)
var wg sync.WaitGroup
for i := 0; i < 2; i++ {
for range 2 {
wg.Add(1)
go func() {
testDelete(t, blobStor, smallObj)

View file

@ -36,7 +36,7 @@ func BenchmarkCompression(b *testing.B) {
func benchWith(b *testing.B, c Config, data []byte) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
_ = c.Compress(data)
}
}

View file

@ -28,7 +28,7 @@ func Benchmark_addressFromString(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for range b.N {
_, err := addressFromString(s)
if err != nil {
b.Fatalf("benchmark error: %v", err)
@ -73,7 +73,7 @@ func TestObjectCounter(t *testing.T) {
eg, egCtx := errgroup.WithContext(context.Background())
eg.Go(func() error {
for j := 0; j < 1_000; j++ {
for range 1_000 {
_, err := fst.Put(egCtx, putPrm)
if err != nil {
return err
@ -84,7 +84,7 @@ func TestObjectCounter(t *testing.T) {
eg.Go(func() error {
var le logicerr.Logical
for j := 0; j < 1_000; j++ {
for range 1_000 {
_, err := fst.Delete(egCtx, delPrm)
if err != nil && !errors.As(err, &le) {
return err

View file

@ -110,7 +110,7 @@ func BenchmarkSubstorageReadPerf(b *testing.B) {
// Fill database
var errG errgroup.Group
for i := 0; i < tt.size; i++ {
for range tt.size {
obj := objGen.Next()
addr := testutil.AddressFromObject(b, obj)
errG.Go(func() error {
@ -203,7 +203,7 @@ func BenchmarkSubstorageIteratePerf(b *testing.B) {
defer func() { require.NoError(b, st.Close()) }()
// Fill database
for i := 0; i < tt.size; i++ {
for range tt.size {
obj := objGen.Next()
addr := testutil.AddressFromObject(b, obj)
raw, err := obj.Marshal()