Skip to content

Commit d25b90c

Browse files
create slice with capacity, when capacity is known
This reduces the number of allocations made to the underlying array, while append() attempts to 'grow' the slice beyond its initial capacity
1 parent bd57f61 commit d25b90c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

play.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ func (r *Recorder) Events() ([]Event, error) {
7979

8080
events := sortedMerge(evOut, evErr)
8181

82-
var (
83-
out []Event
84-
now = epoch
85-
)
82+
now := epoch
83+
out := make([]Event, 0, len(events))
8684

8785
for _, e := range events {
8886
delay := e.time.Sub(now)

0 commit comments

Comments
 (0)