Performance: Add preallocation for some slices (#59593)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package conditions
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
@@ -10,8 +11,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/tsdb/legacydata/interval"
|
||||
"github.com/grafana/grafana/pkg/tsdb/prometheus"
|
||||
|
||||
gocontext "context"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/null"
|
||||
@@ -61,7 +60,7 @@ func (c *QueryCondition) Eval(context *alerting.EvalContext, requestHandler lega
|
||||
// matches represents all the series that violate the alert condition
|
||||
var matches []*alerting.EvalMatch
|
||||
// allMatches capture all evaluation matches irregardless on whether the condition is met or not
|
||||
var allMatches []*alerting.EvalMatch
|
||||
allMatches := make([]*alerting.EvalMatch, 0, len(seriesList))
|
||||
|
||||
for _, series := range seriesList {
|
||||
reducedValue := c.Reducer.Reduce(series)
|
||||
|
||||
@@ -144,6 +144,7 @@ func (gcn *GoogleChatNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||
}
|
||||
|
||||
// add a text paragraph widget for the fields
|
||||
//nolint:prealloc // break block
|
||||
var fields []textParagraphWidget
|
||||
fieldLimitCount := 4
|
||||
for index, evt := range evalContext.EvalMatches {
|
||||
|
||||
Reference in New Issue
Block a user