From fd3fc6656da9a2a79aa74ea5568c6e55f0ee80b9 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 3 Jul 2017 00:55:30 +0100 Subject: [PATCH] refactor: add some more empty report set objects for efficiency and consistency --- report/controls.go | 6 +++--- report/metrics.go | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/report/controls.go b/report/controls.go index 02e87a5b8..9f2815fbf 100644 --- a/report/controls.go +++ b/report/controls.go @@ -56,11 +56,11 @@ type NodeControls struct { Controls StringSet } +var emptyNodeControls = NodeControls{Controls: MakeStringSet()} + // MakeNodeControls makes a new NodeControls func MakeNodeControls() NodeControls { - return NodeControls{ - Controls: MakeStringSet(), - } + return emptyNodeControls } // Copy is a noop, as NodeControls is immutable diff --git a/report/metrics.go b/report/metrics.go index ea1122c92..036c0089e 100644 --- a/report/metrics.go +++ b/report/metrics.go @@ -65,11 +65,13 @@ func MakeSingletonMetric(t time.Time, v float64) Metric { } +var emptyMetric = Metric{} + // MakeMetric makes a new Metric from unique samples incrementally ordered in // time. func MakeMetric(samples []Sample) Metric { if len(samples) < 1 { - return Metric{} + return emptyMetric } var (