aboutsummaryrefslogtreecommitdiffstats
path: root/src/DirectorySave.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-07 21:39:47 +0100
committerMax Kellermann <max@duempel.org>2014-01-09 09:05:58 +0100
commit322b0616322760dc162447563d8f4da7e024ca90 (patch)
tree2f87cb3ce061556161797aba9f57ee08de5b9e21 /src/DirectorySave.cxx
parent43847f2244a34064af24704aac4cfad4a3c76f7d (diff)
downloadmpd-322b0616322760dc162447563d8f4da7e024ca90.tar.gz
mpd-322b0616322760dc162447563d8f4da7e024ca90.tar.xz
mpd-322b0616322760dc162447563d8f4da7e024ca90.zip
DetachedSong: fork of struct Song
From now on, struct Song will be used by the database only, and DetachedSong will be used by everybody else. DetachedSong is easier to use, but Song has lower overhead.
Diffstat (limited to 'src/DirectorySave.cxx')
-rw-r--r--src/DirectorySave.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/DirectorySave.cxx b/src/DirectorySave.cxx
index 709184289..f8ee5b0bd 100644
--- a/src/DirectorySave.cxx
+++ b/src/DirectorySave.cxx
@@ -22,6 +22,7 @@
#include "Directory.hxx"
#include "Song.hxx"
#include "SongSave.hxx"
+#include "DetachedSong.hxx"
#include "PlaylistDatabase.hxx"
#include "fs/TextFile.hxx"
#include "util/StringUtil.hxx"
@@ -132,7 +133,6 @@ directory_load(TextFile &file, Directory &directory, Error &error)
return false;
} else if (StringStartsWith(line, SONG_BEGIN)) {
const char *name = line + sizeof(SONG_BEGIN) - 1;
- Song *song;
if (directory.FindSong(name) != nullptr) {
error.Format(directory_domain,
@@ -140,11 +140,13 @@ directory_load(TextFile &file, Directory &directory, Error &error)
return false;
}
- song = song_load(file, &directory, name, error);
+ DetachedSong *song = song_load(file, name, error);
if (song == nullptr)
return false;
- directory.AddSong(song);
+ directory.AddSong(Song::NewFrom(std::move(*song),
+ &directory));
+ delete song;
} else if (StringStartsWith(line, PLAYLIST_META_BEGIN)) {
const char *name = line + sizeof(PLAYLIST_META_BEGIN) - 1;
if (!playlist_metadata_load(file, directory.playlists,