Performance: Add preallocation for some slices (#59593)

This commit is contained in:
Denis Limarev
2023-01-11 23:03:37 +06:00
committed by GitHub
parent 8bda8b8272
commit 90badc8729
8 changed files with 11 additions and 11 deletions

View File

@@ -118,7 +118,7 @@ func (out *RemoteWriteFrameOutput) sample(timeSeries []prompb.TimeSeries) []prom
sample.Samples = append(sample.Samples, filteredSamples...)
samples[name] = sample
}
var toReturn []prompb.TimeSeries
toReturn := make([]prompb.TimeSeries, 0, len(samples))
for _, ts := range samples {
toReturn = append(toReturn, ts)
}

View File

@@ -309,7 +309,7 @@ func (f *StorageRuleBuilder) BuildRules(ctx context.Context, orgID int64) ([]*Li
return nil, err
}
var rules []*LiveChannelRule
rules := make([]*LiveChannelRule, 0, len(channelRules))
for _, ruleConfig := range channelRules {
rule := &LiveChannelRule{