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/render/detailed/metadata_test.go b/render/detailed/metadata_test.go index ae7715cb3..180e1c39c 100644 --- a/render/detailed/metadata_test.go +++ b/render/detailed/metadata_test.go @@ -47,29 +47,3 @@ func TestNodeMetadata(t *testing.T) { } } } - -func TestMetadataRowCopy(t *testing.T) { - var ( - row = report.MetadataRow{ - ID: "id", - Value: "value", - Priority: 1, - Datatype: "datatype", - } - cp = row.Copy() - ) - - // copy should be identical - if !reflect.DeepEqual(row, cp) { - t.Error(test.Diff(row, cp)) - } - - // changing the copy should not change the original - cp.ID = "" - cp.Value = "" - cp.Priority = 2 - cp.Datatype = "" - if row.ID != "id" || row.Value != "value" || row.Priority != 1 || row.Datatype != "datatype" { - t.Errorf("Expected changing the copy not to modify the original") - } -} 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/metadata_template.go b/report/metadata_template.go index 1775eb4a4..1bee5e642 100644 --- a/report/metadata_template.go +++ b/report/metadata_template.go @@ -28,11 +28,6 @@ type MetadataTemplate struct { From string `json:"from,omitempty"` // Defines how to get the value from a report node } -// Copy returns a value-copy of the template -func (t MetadataTemplate) Copy() MetadataTemplate { - return t -} - // MetadataRows returns the rows for a node func (t MetadataTemplate) MetadataRows(n Node) []MetadataRow { from := fromDefault @@ -90,11 +85,6 @@ type MetadataRow struct { Truncate int `json:"truncate,omitempty"` } -// Copy returns a value copy of a metadata row. -func (m MetadataRow) Copy() MetadataRow { - return m -} - // MetadataTemplates is a mergeable set of metadata templates type MetadataTemplates map[string]MetadataTemplate @@ -115,7 +105,7 @@ func (e MetadataTemplates) Copy() MetadataTemplates { } result := MetadataTemplates{} for k, v := range e { - result[k] = v.Copy() + result[k] = v } return result } diff --git a/report/metric_template.go b/report/metric_template.go index 2c093aac0..9e2d441f0 100644 --- a/report/metric_template.go +++ b/report/metric_template.go @@ -34,11 +34,6 @@ func (t MetricTemplate) MetricRows(n Node) []MetricRow { return []MetricRow{row} } -// Copy returns a value-copy of the metric template -func (t MetricTemplate) Copy() MetricTemplate { - return t -} - // MetricTemplates is a mergeable set of metric templates type MetricTemplates map[string]MetricTemplate @@ -59,7 +54,7 @@ func (e MetricTemplates) Copy() MetricTemplates { } result := MetricTemplates{} for k, v := range e { - result[k] = v.Copy() + result[k] = v } return result } 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"` diff --git a/test/utils/prune.go b/test/utils/prune.go index 8e158636a..42a8aa268 100644 --- a/test/utils/prune.go +++ b/test/utils/prune.go @@ -25,6 +25,6 @@ func PruneNode(node report.Node) report.Node { return report.MakeNode( node.ID). WithTopology(node.Topology). - WithAdjacent(node.Adjacency.Copy()...). + WithAdjacent(node.Adjacency...). WithChildren(prunedChildren) }