From 4dbb913ca2644ee28069c88ddf80c6e38b279321 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 4 Jul 2017 06:59:47 +0100 Subject: [PATCH] refactor: remove dead Copy() code --- extras/generate_latest_map | 5 ----- report/controls.go | 5 ----- report/counters.go | 5 ----- report/edge_metadatas.go | 5 ----- report/id_list.go | 5 ----- report/latest_map_generated.go | 10 ---------- report/node_set.go | 5 ----- report/sets.go | 5 ----- report/string_set.go | 10 ---------- report/table.go | 28 ---------------------------- 10 files changed, 83 deletions(-) diff --git a/extras/generate_latest_map b/extras/generate_latest_map index 8dfddc860..f55ce67c4 100755 --- a/extras/generate_latest_map +++ b/extras/generate_latest_map @@ -70,11 +70,6 @@ function generate_latest_map() { return ${empty_latest_map_variable} } - // Copy is a noop, as ${latest_map_type}s are immutable. - func (m ${latest_map_type}) Copy() ${latest_map_type} { - return m - } - // Size returns the number of elements. func (m ${latest_map_type}) Size() int { if m.Map == nil { diff --git a/report/controls.go b/report/controls.go index 9f2815fbf..6a9f06541 100644 --- a/report/controls.go +++ b/report/controls.go @@ -63,11 +63,6 @@ func MakeNodeControls() NodeControls { return emptyNodeControls } -// Copy is a noop, as NodeControls is immutable -func (nc NodeControls) Copy() NodeControls { - return nc -} - // Merge returns the newest of the two NodeControls; it does not take the union // of the valid Controls. func (nc NodeControls) Merge(other NodeControls) NodeControls { diff --git a/report/counters.go b/report/counters.go index f75493dbe..8bb494dcd 100644 --- a/report/counters.go +++ b/report/counters.go @@ -21,11 +21,6 @@ func MakeCounters() Counters { return emptyCounters } -// Copy is a noop -func (c Counters) Copy() Counters { - return c -} - // Add value to the counter 'key' func (c Counters) Add(key string, value int) Counters { if c.psMap == nil { diff --git a/report/edge_metadatas.go b/report/edge_metadatas.go index 5300fa143..d8f915656 100644 --- a/report/edge_metadatas.go +++ b/report/edge_metadatas.go @@ -22,11 +22,6 @@ func MakeEdgeMetadatas() EdgeMetadatas { return emptyEdgeMetadatas } -// Copy is a noop -func (c EdgeMetadatas) Copy() EdgeMetadatas { - return c -} - // Add value to the counter 'key' func (c EdgeMetadatas) Add(key string, value EdgeMetadata) EdgeMetadatas { if c.psMap == nil { diff --git a/report/id_list.go b/report/id_list.go index 049dada0e..259b1d3b7 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...)) } -// Copy returns a copy of the IDList. -func (a IDList) Copy() IDList { - return IDList(StringSet(a).Copy()) -} - // Merge all elements from a and b into a new list func (a IDList) Merge(b IDList) IDList { return IDList(StringSet(a).Merge(StringSet(b))) diff --git a/report/latest_map_generated.go b/report/latest_map_generated.go index f7fee95a0..570f6846c 100644 --- a/report/latest_map_generated.go +++ b/report/latest_map_generated.go @@ -37,11 +37,6 @@ func MakeStringLatestMap() StringLatestMap { return emptyStringLatestMap } -// Copy is a noop, as StringLatestMaps are immutable. -func (m StringLatestMap) Copy() StringLatestMap { - return m -} - // Size returns the number of elements. func (m StringLatestMap) Size() int { if m.Map == nil { @@ -168,11 +163,6 @@ func MakeNodeControlDataLatestMap() NodeControlDataLatestMap { return emptyNodeControlDataLatestMap } -// Copy is a noop, as NodeControlDataLatestMaps are immutable. -func (m NodeControlDataLatestMap) Copy() NodeControlDataLatestMap { - return m -} - // Size returns the number of elements. func (m NodeControlDataLatestMap) Size() int { if m.Map == nil { diff --git a/report/node_set.go b/report/node_set.go index 3c4ba7141..5331b3996 100644 --- a/report/node_set.go +++ b/report/node_set.go @@ -103,11 +103,6 @@ func (n NodeSet) ForEach(f func(Node)) { } } -// Copy is a noop -func (n NodeSet) Copy() NodeSet { - return n -} - func (n NodeSet) String() string { buf := bytes.NewBufferString("{") for _, key := range mapKeys(n.psMap) { diff --git a/report/sets.go b/report/sets.go index 61d7ec71f..2775dbeaa 100644 --- a/report/sets.go +++ b/report/sets.go @@ -102,11 +102,6 @@ func (s Sets) Merge(other Sets) Sets { return Sets{result} } -// Copy is a noop -func (s Sets) Copy() Sets { - return s -} - func (s Sets) String() string { return mapToString(s.psMap) } diff --git a/report/string_set.go b/report/string_set.go index f9193427b..d3ba3645b 100644 --- a/report/string_set.go +++ b/report/string_set.go @@ -97,13 +97,3 @@ func (s StringSet) Merge(other StringSet) StringSet { } } } - -// Copy returns a value copy of the StringSet. -func (s StringSet) Copy() StringSet { - if s == nil { - return s - } - result := make(StringSet, len(s)) - copy(result, s) - return result -} diff --git a/report/table.go b/report/table.go index 134388803..859a8c1f1 100644 --- a/report/table.go +++ b/report/table.go @@ -175,16 +175,6 @@ func (t rowsByID) Len() int { return len(t) } func (t rowsByID) Swap(i, j int) { t[i], t[j] = t[j], t[i] } func (t rowsByID) Less(i, j int) bool { return t[i].ID < t[j].ID } -// Copy returns a copy of the Row. -func (r Row) Copy() Row { - entriesCopy := make(map[string]string, len(r.Entries)) - for key, value := range r.Entries { - entriesCopy[key] = value - } - r.Entries = entriesCopy - return r -} - // Table is the type for a table in the UI. type Table struct { ID string `json:"id"` @@ -201,24 +191,6 @@ func (t tablesByID) Len() int { return len(t) } func (t tablesByID) Swap(i, j int) { t[i], t[j] = t[j], t[i] } func (t tablesByID) Less(i, j int) bool { return t[i].ID < t[j].ID } -// Copy returns a copy of the Table. -func (t Table) Copy() Table { - result := Table{ - ID: t.ID, - Label: t.Label, - Type: t.Type, - Columns: make([]Column, 0, len(t.Columns)), - Rows: make([]Row, 0, len(t.Rows)), - } - for _, column := range t.Columns { - result.Columns = append(result.Columns, column) - } - for _, row := range t.Rows { - result.Rows = append(result.Rows, row) - } - return result -} - // TableTemplate describes how to render a table for the UI. type TableTemplate struct { ID string `json:"id"`