diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-07-28 13:07:16 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2023-07-28 13:07:16 +0200 |
| commit | 7471cb64e9b7d8e6b1cabb07751181bbfdf3237c (patch) | |
| tree | 35ef4c43312bdb0bc9214d83f43c368043104825 /playlist.go | |
| parent | 1fbf611500260cb78b36abd5cf95feeb211be6bc (diff) | |
| download | WRMS-7471cb64e9b7d8e6b1cabb07751181bbfdf3237c.tar.gz WRMS-7471cb64e9b7d8e6b1cabb07751181bbfdf3237c.zip | |
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.
Diffstat (limited to 'playlist.go')
| -rw-r--r-- | playlist.go | 4 |
1 files changed, 3 insertions, 1 deletions
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 } |
