From 7471cb64e9b7d8e6b1cabb07751181bbfdf3237c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 28 Jul 2023 13:07:16 +0200 Subject: fix copying of the playlist when creating an ordered list Go's copy builtin does only copy min(len(dest), len(src)) elements, since we create an empty destination slice with a big enough capacity copy does not actually copy anything. --- playlist.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'playlist.go') diff --git a/playlist.go b/playlist.go index cb9c90c..bc410e3 100644 --- a/playlist.go +++ b/playlist.go @@ -65,13 +65,15 @@ func (pl *Playlist) RemoveSong(s *Song) { func (pl *Playlist) OrderedList() []*Song { songs := make([]*Song, 0, pl.Len()) - cpy := make(Playlist, 0, pl.Len()) + cpy := make(Playlist, pl.Len()) copy(cpy, *pl) + llog.DDebug("copying %v returned %v", *pl, cpy) for cpy.Len() > 0 { songs = append(songs, heap.Pop(&cpy).(*Song)) } + llog.DDebug("ordering queue %v returned %v", pl, songs) return songs } -- cgit v1.2.3