From 4fc389edcbdb8275071050b316ff15ae3bdf8fda Mon Sep 17 00:00:00 2001 From: davy Date: Wed, 3 Jul 2019 07:54:22 -0500 Subject: [PATCH] optimize allocation --- pkg/media/library.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/media/library.go b/pkg/media/library.go index c0d79eb..3d58aab 100644 --- a/pkg/media/library.go +++ b/pkg/media/library.go @@ -74,9 +74,11 @@ func (lib *Library) Remove(path string) { func (lib *Library) Playlist() Playlist { lib.mu.RLock() defer lib.mu.RUnlock() - pl := make(Playlist, 0) + pl := make(Playlist, len(lib.Videos)) + i := 0 for _, v := range lib.Videos { - pl = append(pl, v) + pl[i] = v + i++ } sort.Sort(pl) return pl