From 612222b693a46e6a79dcf097857aafb15c8afde8 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Mon, 15 Jul 2019 11:30:19 +0200 Subject: [PATCH] dispatch: use strings.Builder instead of []byte Signed-off-by: Simon Pasquier --- dispatch/route.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dispatch/route.go b/dispatch/route.go index 928d641a..43c48c25 100644 --- a/dispatch/route.go +++ b/dispatch/route.go @@ -17,6 +17,7 @@ import ( "encoding/json" "fmt" "sort" + "strings" "time" "github.com/prometheus/common/model" @@ -142,15 +143,16 @@ func (r *Route) Match(lset model.LabelSet) []*Route { return all } -// Key returns a key for the route. It does not uniquely identify a the route in general. +// Key returns a key for the route. It does not uniquely identify the route in general. func (r *Route) Key() string { - b := make([]byte, 0, 1024) + b := strings.Builder{} if r.parent != nil { - b = append(b, r.parent.Key()...) - b = append(b, '/') + b.WriteString(r.parent.Key()) + b.WriteRune('/') } - return string(append(b, r.Matchers.String()...)) + b.WriteString(r.Matchers.String()) + return b.String() } // RouteOpts holds various routing options necessary for processing alerts