From a4cd5de795926537318f94aa34c9f2579c29fc11 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sun, 19 Jun 2022 16:45:23 +0000 Subject: ref: Make the slice at once A small optimization, it will create the slice at once so it won't to expand multiple time later when append is called. --- worker/worker.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worker/worker.go b/worker/worker.go index f56716f..06fac36 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -91,10 +91,12 @@ func (w *Worker) StartWorker(model db.EntryModel) { } func (w *Worker) GetJobs() []Job { - jobs := []Job{} + jobs := make([]Job, len(w.jobs)) + count := 0 for k, v := range w.jobs { - jobs = append(jobs, Job{Id: k, Status: v}) + jobs[count] = Job{Id: k, Status: v} + count++ } return jobs -- cgit v1.2.3