Skip to content

Commit

Permalink
Merge pull request prometheus#1963 from simonpasquier/refactor-dispat…
Browse files Browse the repository at this point in the history
…ch-route

dispatch: use strings.Builder instead of []byte
  • Loading branch information
mxinden authored Jul 16, 2019
2 parents 9b0ecaa + 612222b commit 4706dc7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dispatch/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"encoding/json"
"fmt"
"sort"
"strings"
"time"

"github.com/prometheus/common/model"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4706dc7

Please sign in to comment.