From b199c791b5594542ef1a32ed77804074d4f3060b Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sat, 5 Aug 2023 14:40:04 -0700 Subject: [PATCH] [chore]preallocate slice --- exporter/datasetexporter/traces_exporter.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exporter/datasetexporter/traces_exporter.go b/exporter/datasetexporter/traces_exporter.go index a2bf4fb65709..a8e8de5e2553 100644 --- a/exporter/datasetexporter/traces_exporter.go +++ b/exporter/datasetexporter/traces_exporter.go @@ -134,7 +134,6 @@ type spanBundle struct { } func buildEventsFromTraces(ld ptrace.Traces, serverHost string) []*add_events.EventBundle { - var events []*add_events.EventBundle var spans = make([]spanBundle, 0) // convert spans into events @@ -152,8 +151,9 @@ func buildEventsFromTraces(ld ptrace.Traces, serverHost string) []*add_events.Ev } } - for _, span := range spans { - events = append(events, buildEventFromSpan(span, serverHost)) + events := make([]*add_events.EventBundle, len(spans)) + for i, span := range spans { + events[i] = buildEventFromSpan(span, serverHost) } return events