Perfomance: Preallocate slices (#61580)
This commit is contained in:
@@ -403,7 +403,7 @@ func (am *Alertmanager) buildIntegrationsMap(receivers []*apimodels.PostableApiR
|
||||
|
||||
// buildReceiverIntegrations builds a list of integration notifiers off of a receiver config.
|
||||
func (am *Alertmanager) buildReceiverIntegrations(receiver *apimodels.PostableApiReceiver, tmpl *alerting.Template) ([]*alerting.Integration, error) {
|
||||
var integrations []*alerting.Integration
|
||||
integrations := make([]*alerting.Integration, 0, len(receiver.GrafanaManagedReceivers))
|
||||
for i, r := range receiver.GrafanaManagedReceivers {
|
||||
n, err := am.buildReceiverIntegration(r, tmpl)
|
||||
if err != nil {
|
||||
|
||||
@@ -130,7 +130,7 @@ func (am *Alertmanager) GetReceivers(ctx context.Context) []apimodels.Receiver {
|
||||
am.reloadConfigMtx.RLock()
|
||||
defer am.reloadConfigMtx.RUnlock()
|
||||
|
||||
var apiReceivers []apimodels.Receiver
|
||||
apiReceivers := make([]apimodels.Receiver, 0, len(am.Base.GetReceivers()))
|
||||
for _, rcv := range am.Base.GetReceivers() {
|
||||
// Build integrations slice for each receiver.
|
||||
integrations := make([]*models.Integration, 0, len(rcv.Integrations()))
|
||||
|
||||
Reference in New Issue
Block a user