Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dispatch: use strings.Builder instead of []byte #1963

Merged
merged 1 commit into from
Jul 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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