From a187e0474906d12571f95e0a9a94eea65963bf3c Mon Sep 17 00:00:00 2001 From: lrita Date: Tue, 30 Jul 2019 18:58:48 +0800 Subject: [PATCH] reduce unnecessary allocate in GetOrRegisterGaugeFloat64() --- gauge_float64.go | 2 +- gauge_float64_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gauge_float64.go b/gauge_float64.go index 3962e6d..527ffe7 100644 --- a/gauge_float64.go +++ b/gauge_float64.go @@ -18,7 +18,7 @@ func GetOrRegisterGaugeFloat64(name string, r Registry) GaugeFloat64 { if nil == r { r = DefaultRegistry } - return r.GetOrRegister(name, NewGaugeFloat64()).(GaugeFloat64) + return r.GetOrRegister(name, NewGaugeFloat64).(GaugeFloat64) } // NewGaugeFloat64 constructs a new StandardGaugeFloat64. diff --git a/gauge_float64_test.go b/gauge_float64_test.go index 6769b95..5dae11f 100644 --- a/gauge_float64_test.go +++ b/gauge_float64_test.go @@ -66,4 +66,7 @@ func TestGetOrRegisterFunctionalGaugeFloat64(t *testing.T) { if g := GetOrRegisterGaugeFloat64("foo", r); 47 != g.Value() { t.Fatal(g) } + if g := GetOrRegisterGaugeFloat64("foo.xxx", r); 0.0 != g.Value() { + t.Fatal(g) + } }