From 5b131b1ea6985c102de6aaeb310fc564e2b78e03 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 3 Jul 2017 01:13:59 +0100 Subject: [PATCH] refactor: remove a couple of report set Remove() functions They were unused and their naming was inconsistent with similar operations (that are called Delete()). --- report/id_list.go | 5 ----- report/string_set.go | 15 --------------- report/topology_test.go | 21 --------------------- 3 files changed, 41 deletions(-) diff --git a/report/id_list.go b/report/id_list.go index d75df56c3..049dada0e 100644 --- a/report/id_list.go +++ b/report/id_list.go @@ -21,11 +21,6 @@ func (a IDList) Add(ids ...string) IDList { return IDList(StringSet(a).Add(ids...)) } -// Remove is the only correct way to remove IDs from an IDList. -func (a IDList) Remove(ids ...string) IDList { - return IDList(StringSet(a).Remove(ids...)) -} - // Copy returns a copy of the IDList. func (a IDList) Copy() IDList { return IDList(StringSet(a).Copy()) diff --git a/report/string_set.go b/report/string_set.go index d0b63a50f..f9193427b 100644 --- a/report/string_set.go +++ b/report/string_set.go @@ -67,21 +67,6 @@ func (s StringSet) Add(strs ...string) StringSet { return s } -// Remove removes the strings from the StringSet. Remove is the only valid way -// to shrink a StringSet. Remove returns the StringSet to enable chaining. -func (s StringSet) Remove(strs ...string) StringSet { - for _, str := range strs { - i := sort.Search(len(s), func(i int) bool { return s[i] >= str }) - if i >= len(s) || s[i] != str { - // The list does not have the element. - continue - } - // has the element, remove it. - s = append(s[:i], s[i+1:]...) - } - return s -} - // Merge combines the two StringSets and returns a new result. func (s StringSet) Merge(other StringSet) StringSet { switch { diff --git a/report/topology_test.go b/report/topology_test.go index dccb6a40f..08ca1a2b1 100644 --- a/report/topology_test.go +++ b/report/topology_test.go @@ -45,27 +45,6 @@ func TestStringSetAdd(t *testing.T) { } } -func TestStringSetRemove(t *testing.T) { - for _, testcase := range []struct { - input report.StringSet - strs []string - want report.StringSet - }{ - {input: report.StringSet(nil), strs: []string{}, want: report.StringSet(nil)}, - {input: report.MakeStringSet(), strs: []string{}, want: report.MakeStringSet()}, - {input: report.MakeStringSet("a"), strs: []string{}, want: report.MakeStringSet("a")}, - {input: report.MakeStringSet(), strs: []string{"a"}, want: report.MakeStringSet()}, - {input: report.MakeStringSet("a"), strs: []string{"a"}, want: report.StringSet{}}, - {input: report.MakeStringSet("b"), strs: []string{"a", "b"}, want: report.StringSet{}}, - {input: report.MakeStringSet("a"), strs: []string{"c", "b"}, want: report.MakeStringSet("a")}, - {input: report.MakeStringSet("a", "c"), strs: []string{"b", "b", "b"}, want: report.MakeStringSet("a", "c")}, - } { - if want, have := testcase.want, testcase.input.Remove(testcase.strs...); !reflect.DeepEqual(want, have) { - t.Errorf("%v - %v: want %#v, have %#v", testcase.input, testcase.strs, want, have) - } - } -} - func TestStringSetMerge(t *testing.T) { for _, testcase := range []struct { input report.StringSet