Use range
over int
after 1.22 upgrade #113
7 changed files with 14 additions and 14 deletions
|
@ -37,6 +37,6 @@ repos:
|
||||||
language: system
|
language: system
|
||||||
|
|
||||||
- repo: https://github.com/golangci/golangci-lint
|
- repo: https://github.com/golangci/golangci-lint
|
||||||
rev: v1.56.2
|
rev: v1.60.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: golangci-lint
|
- id: golangci-lint
|
||||||
|
|
|
@ -32,7 +32,7 @@ func BenchmarkTable_ToGRPCMessage(b *testing.B) {
|
||||||
|
|
||||||
b.Run("to grpc message", func(b *testing.B) {
|
b.Run("to grpc message", func(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
raw := tb.ToGRPCMessage()
|
raw := tb.ToGRPCMessage()
|
||||||
if len(tb.GetRecords()) != len(raw.(*aclGrpc.EACLTable).Records) {
|
if len(tb.GetRecords()) != len(raw.(*aclGrpc.EACLTable).Records) {
|
||||||
b.FailNow()
|
b.FailNow()
|
||||||
|
@ -41,7 +41,7 @@ func BenchmarkTable_ToGRPCMessage(b *testing.B) {
|
||||||
})
|
})
|
||||||
b.Run("from grpc message", func(b *testing.B) {
|
b.Run("from grpc message", func(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
tb := new(acl.Table)
|
tb := new(acl.Table)
|
||||||
if tb.FromGRPCMessage(raw) != nil {
|
if tb.FromGRPCMessage(raw) != nil {
|
||||||
b.FailNow()
|
b.FailNow()
|
||||||
|
|
|
@ -525,7 +525,7 @@ func (x *NetworkConfig) ToGRPCMessage() grpc.Message {
|
||||||
if ln := len(x.ps); ln > 0 {
|
if ln := len(x.ps); ln > 0 {
|
||||||
ps = make([]netmap.NetworkConfig_Parameter, 0, ln)
|
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))
|
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)
|
ps = make([]NetworkParameter, ln)
|
||||||
|
|
||||||
for i := 0; i < ln; i++ {
|
for i := range ln {
|
||||||
if err := ps[i].FromGRPCMessage(&psV2[i]); err != nil {
|
if err := ps[i].FromGRPCMessage(&psV2[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func BenchmarkAttributesMarshal(b *testing.B) {
|
||||||
|
|
||||||
b.Run("marshal", func(b *testing.B) {
|
b.Run("marshal", func(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
res := AttributesToGRPC(attrs)
|
res := AttributesToGRPC(attrs)
|
||||||
if len(res) != len(raw) {
|
if len(res) != len(raw) {
|
||||||
b.FailNow()
|
b.FailNow()
|
||||||
|
@ -35,7 +35,7 @@ func BenchmarkAttributesMarshal(b *testing.B) {
|
||||||
})
|
})
|
||||||
b.Run("unmarshal", func(b *testing.B) {
|
b.Run("unmarshal", func(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
res, err := AttributesFromGRPC(raw)
|
res, err := AttributesFromGRPC(raw)
|
||||||
if err != nil || len(res) != len(raw) {
|
if err != nil || len(res) != len(raw) {
|
||||||
b.FailNow()
|
b.FailNow()
|
||||||
|
|
|
@ -24,7 +24,7 @@ func benchmarkObjectIDSlice(b *testing.B, size int) {
|
||||||
|
|
||||||
b.Run("to grpc message", func(b *testing.B) {
|
b.Run("to grpc message", func(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
raw := ObjectIDListToGRPCMessage(ids)
|
raw := ObjectIDListToGRPCMessage(ids)
|
||||||
if len(raw) != len(ids) {
|
if len(raw) != len(ids) {
|
||||||
b.FailNow()
|
b.FailNow()
|
||||||
|
@ -33,7 +33,7 @@ func benchmarkObjectIDSlice(b *testing.B, size int) {
|
||||||
})
|
})
|
||||||
b.Run("from grpc message", func(b *testing.B) {
|
b.Run("from grpc message", func(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
ids, err := ObjectIDListFromGRPCMessage(raw)
|
ids, err := ObjectIDListFromGRPCMessage(raw)
|
||||||
if err != nil || len(raw) != len(ids) {
|
if err != nil || len(raw) != len(ids) {
|
||||||
b.FailNow()
|
b.FailNow()
|
||||||
|
@ -42,7 +42,7 @@ func benchmarkObjectIDSlice(b *testing.B, size int) {
|
||||||
})
|
})
|
||||||
b.Run("marshal", func(b *testing.B) {
|
b.Run("marshal", func(b *testing.B) {
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
buf := make([]byte, ObjectIDNestedListSize(1, ids))
|
buf := make([]byte, ObjectIDNestedListSize(1, ids))
|
||||||
n := ObjectIDNestedListMarshal(1, buf, ids)
|
n := ObjectIDNestedListMarshal(1, buf, ids)
|
||||||
if n != len(buf) {
|
if n != len(buf) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ func BenchmarkSignRequest(b *testing.B) {
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
dec := new(accounting.Decimal)
|
dec := new(accounting.Decimal)
|
||||||
dec.SetValue(100)
|
dec.SetValue(100)
|
||||||
|
@ -103,7 +103,7 @@ func BenchmarkVerifyRequest(b *testing.B) {
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
for range b.N {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
dec := new(accounting.Decimal)
|
dec := new(accounting.Decimal)
|
||||||
dec.SetValue(100)
|
dec.SetValue(100)
|
||||||
|
|
|
@ -53,7 +53,7 @@ func (x *Status) ToGRPCMessage() grpc.Message {
|
||||||
if ln := len(x.details); ln > 0 {
|
if ln := len(x.details); ln > 0 {
|
||||||
ds = make([]status.Status_Detail, 0, ln)
|
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))
|
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)
|
ds = make([]Detail, ln)
|
||||||
|
|
||||||
for i := 0; i < ln; i++ {
|
for i := range ln {
|
||||||
if err := ds[i].FromGRPCMessage(&dsV2[i]); err != nil {
|
if err := ds[i].FromGRPCMessage(&dsV2[i]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue