add some handler performance improvements

This commit is contained in:
sentriz
2019-07-08 15:43:45 +01:00
parent 5a1d262d6b
commit 22b53e8c17
2 changed files with 16 additions and 13 deletions

View File

@@ -147,9 +147,11 @@ func (c *Controller) GetAlbumList(w http.ResponseWriter, r *http.Request) {
Preload("Parent").
Find(&folders)
sub := subsonic.NewResponse()
sub.Albums = &subsonic.Albums{}
for _, folder := range folders {
sub.Albums.List = append(sub.Albums.List, newAlbumByFolder(folder))
sub.Albums = &subsonic.Albums{
List: make([]*subsonic.Album, len(folders)),
}
for i, folder := range folders {
sub.Albums.List[i] = newAlbumByFolder(folder)
}
respond(w, r, sub)
}