refactor: add some more empty report set objects

for efficiency and consistency
This commit is contained in:
Matthias Radestock
2017-07-03 00:55:30 +01:00
parent b5f3aa68ae
commit fd3fc6656d
2 changed files with 6 additions and 4 deletions

View File

@@ -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

View File

@@ -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 (