dispatch: use strings.Builder instead of []byte

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2019-07-15 11:30:19 +02:00
parent 9b0ecaa0fe
commit 612222b693
1 changed files with 7 additions and 5 deletions

View File

@ -17,6 +17,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"sort" "sort"
"strings"
"time" "time"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
@ -142,15 +143,16 @@ func (r *Route) Match(lset model.LabelSet) []*Route {
return all 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 { func (r *Route) Key() string {
b := make([]byte, 0, 1024) b := strings.Builder{}
if r.parent != nil { if r.parent != nil {
b = append(b, r.parent.Key()...) b.WriteString(r.parent.Key())
b = append(b, '/') 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 // RouteOpts holds various routing options necessary for processing alerts