From d4a8b1755c7e126a120eeacce29900224ff92aa8 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 11 Mar 2022 11:53:48 +0300 Subject: [PATCH] [#168] audit: Replace []*oid.ID with []oid.ID Signed-off-by: Alex Vanin --- audit/result.go | 24 ++++++++++++------------ audit/result_test.go | 4 ++-- audit/test/generate.go | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/audit/result.go b/audit/result.go index 1494bae1..11cc8941 100644 --- a/audit/result.go +++ b/audit/result.go @@ -141,7 +141,7 @@ func (r *Result) SetRetries(v uint32) { } // PassSG returns list of Storage Groups that passed audit PoR stage. -func (r *Result) PassSG() []*oid.ID { +func (r *Result) PassSG() []oid.ID { mV2 := (*audit.DataAuditResult)(r). GetPassSG() @@ -149,17 +149,17 @@ func (r *Result) PassSG() []*oid.ID { return nil } - m := make([]*oid.ID, len(mV2)) + m := make([]oid.ID, len(mV2)) for i := range mV2 { - m[i] = oid.NewIDFromV2(mV2[i]) + m[i] = *oid.NewIDFromV2(&mV2[i]) } return m } // SetPassSG sets list of Storage Groups that passed audit PoR stage. -func (r *Result) SetPassSG(list []*oid.ID) { +func (r *Result) SetPassSG(list []oid.ID) { mV2 := (*audit.DataAuditResult)(r). GetPassSG() @@ -171,11 +171,11 @@ func (r *Result) SetPassSG(list []*oid.ID) { if cap(mV2) >= ln { mV2 = mV2[:0] } else { - mV2 = make([]*refs.ObjectID, 0, ln) + mV2 = make([]refs.ObjectID, ln) } for i := 0; i < ln; i++ { - mV2 = append(mV2, list[i].ToV2()) + mV2[i] = *list[i].ToV2() } } @@ -183,7 +183,7 @@ func (r *Result) SetPassSG(list []*oid.ID) { } // FailSG returns list of Storage Groups that failed audit PoR stage. -func (r *Result) FailSG() []*oid.ID { +func (r *Result) FailSG() []oid.ID { mV2 := (*audit.DataAuditResult)(r). GetFailSG() @@ -191,17 +191,17 @@ func (r *Result) FailSG() []*oid.ID { return nil } - m := make([]*oid.ID, len(mV2)) + m := make([]oid.ID, len(mV2)) for i := range mV2 { - m[i] = oid.NewIDFromV2(mV2[i]) + m[i] = *oid.NewIDFromV2(&mV2[i]) } return m } // SetFailSG sets list of Storage Groups that failed audit PoR stage. -func (r *Result) SetFailSG(list []*oid.ID) { +func (r *Result) SetFailSG(list []oid.ID) { mV2 := (*audit.DataAuditResult)(r). GetFailSG() @@ -213,11 +213,11 @@ func (r *Result) SetFailSG(list []*oid.ID) { if cap(mV2) >= ln { mV2 = mV2[:0] } else { - mV2 = make([]*refs.ObjectID, 0, ln) + mV2 = make([]refs.ObjectID, ln) } for i := 0; i < ln; i++ { - mV2 = append(mV2, list[i].ToV2()) + mV2[i] = *list[i].ToV2() } } diff --git a/audit/result_test.go b/audit/result_test.go index c9e37bc7..cb5d7daf 100644 --- a/audit/result_test.go +++ b/audit/result_test.go @@ -40,11 +40,11 @@ func TestResult(t *testing.T) { r.SetRetries(retries) require.Equal(t, retries, r.Retries()) - passSG := []*oid.ID{oidtest.ID(), oidtest.ID()} + passSG := []oid.ID{*oidtest.ID(), *oidtest.ID()} r.SetPassSG(passSG) require.Equal(t, passSG, r.PassSG()) - failSG := []*oid.ID{oidtest.ID(), oidtest.ID()} + failSG := []oid.ID{*oidtest.ID(), *oidtest.ID()} r.SetFailSG(failSG) require.Equal(t, failSG, r.FailSG()) diff --git a/audit/test/generate.go b/audit/test/generate.go index 76affc3f..4da015a0 100644 --- a/audit/test/generate.go +++ b/audit/test/generate.go @@ -30,8 +30,8 @@ func Result() *audit.Result { []byte("node3"), []byte("node4"), }) - x.SetPassSG([]*oid.ID{oidtest.ID(), oidtest.ID()}) - x.SetFailSG([]*oid.ID{oidtest.ID(), oidtest.ID()}) + x.SetPassSG([]oid.ID{*oidtest.ID(), *oidtest.ID()}) + x.SetFailSG([]oid.ID{*oidtest.ID(), *oidtest.ID()}) return x }