From 9322b54b68e5b314b742c5981afd3b3f85b6aa28 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sat, 30 Sep 2017 14:33:20 +0000 Subject: [PATCH] Stop causing errors by parsing empty strings as time.Time We encode the zero time as an empty string, so we should do the reverse when decoding. Otherwise time.Parse() returns an error, which is created on the heap, causing extra garbage-collection load. --- report/metrics.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/report/metrics.go b/report/metrics.go index 036c0089e..63315c622 100644 --- a/report/metrics.go +++ b/report/metrics.go @@ -238,6 +238,9 @@ func renderTime(t time.Time) string { } func parseTime(s string) time.Time { + if s == "" { + return time.Time{} + } t, _ := time.Parse(time.RFC3339Nano, s) return t }