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
This commit is contained in:
Aditya Harindar 2019-10-28 15:45:30 +05:30
Родитель bd57f61ee0
Коммит d25b90cb6a
1 изменённых файлов: 2 добавлений и 4 удалений

Просмотреть файл

@ -79,10 +79,8 @@ func (r *Recorder) Events() ([]Event, error) {
events := sortedMerge(evOut, evErr)
var (
out []Event
now = epoch
)
now := epoch
out := make([]Event, 0, len(events))
for _, e := range events {
delay := e.time.Sub(now)