Use range over int after 1.22 upgrade #113

Merged
fyrchik merged 2 commits from elebedeva/frostfs-api-go:feat/range-over-int-go1.22 into master 2024-11-02 14:21:46 +00:00
7 changed files with 14 additions and 14 deletions

View file

@ -37,6 +37,6 @@ repos:
language: system
- repo: https://github.com/golangci/golangci-lint
rev: v1.56.2
rev: v1.60.3
hooks:
- id: golangci-lint

View file

@ -32,7 +32,7 @@ func BenchmarkTable_ToGRPCMessage(b *testing.B) {
b.Run("to grpc message", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
raw := tb.ToGRPCMessage()
if len(tb.GetRecords()) != len(raw.(*aclGrpc.EACLTable).Records) {
b.FailNow()
@ -41,7 +41,7 @@ func BenchmarkTable_ToGRPCMessage(b *testing.B) {
})
b.Run("from grpc message", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
tb := new(acl.Table)
if tb.FromGRPCMessage(raw) != nil {
b.FailNow()

View file

@ -525,7 +525,7 @@ func (x *NetworkConfig) ToGRPCMessage() grpc.Message {
if ln := len(x.ps); ln > 0 {
ps = make([]netmap.NetworkConfig_Parameter, 0, ln)
for i := 0; i < ln; i++ {
for i := range ln {
ps = append(ps, *x.ps[i].ToGRPCMessage().(*netmap.NetworkConfig_Parameter))
}
}
@ -552,7 +552,7 @@ func (x *NetworkConfig) FromGRPCMessage(m grpc.Message) error {
ps = make([]NetworkParameter, ln)
for i := 0; i < ln; i++ {
for i := range ln {
if err := ps[i].FromGRPCMessage(&psV2[i]); err != nil {
return err
}

View file

@ -26,7 +26,7 @@ func BenchmarkAttributesMarshal(b *testing.B) {
b.Run("marshal", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
res := AttributesToGRPC(attrs)
if len(res) != len(raw) {
b.FailNow()
@ -35,7 +35,7 @@ func BenchmarkAttributesMarshal(b *testing.B) {
})
b.Run("unmarshal", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
res, err := AttributesFromGRPC(raw)
if err != nil || len(res) != len(raw) {
b.FailNow()

View file

@ -24,7 +24,7 @@ func benchmarkObjectIDSlice(b *testing.B, size int) {
b.Run("to grpc message", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
raw := ObjectIDListToGRPCMessage(ids)
if len(raw) != len(ids) {
b.FailNow()
@ -33,7 +33,7 @@ func benchmarkObjectIDSlice(b *testing.B, size int) {
})
b.Run("from grpc message", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
ids, err := ObjectIDListFromGRPCMessage(raw)
if err != nil || len(raw) != len(ids) {
b.FailNow()
@ -42,7 +42,7 @@ func benchmarkObjectIDSlice(b *testing.B, size int) {
})
b.Run("marshal", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
buf := make([]byte, ObjectIDNestedListSize(1, ids))
n := ObjectIDNestedListMarshal(1, buf, ids)
if n != len(buf) {

View file

@ -77,7 +77,7 @@ func BenchmarkSignRequest(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
b.StopTimer()
dec := new(accounting.Decimal)
dec.SetValue(100)
@ -103,7 +103,7 @@ func BenchmarkVerifyRequest(b *testing.B) {
b.ResetTimer()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
for range b.N {
b.StopTimer()
dec := new(accounting.Decimal)
dec.SetValue(100)

View file

@ -53,7 +53,7 @@ func (x *Status) ToGRPCMessage() grpc.Message {
if ln := len(x.details); ln > 0 {
ds = make([]status.Status_Detail, 0, ln)
for i := 0; i < ln; i++ {
for i := range ln {
ds = append(ds, *x.details[i].ToGRPCMessage().(*status.Status_Detail))
}
}
@ -80,7 +80,7 @@ func (x *Status) FromGRPCMessage(m grpc.Message) error {
ds = make([]Detail, ln)
for i := 0; i < ln; i++ {
for i := range ln {
if err := ds[i].FromGRPCMessage(&dsV2[i]); err != nil {
return err
}