diff options
author | Max Kellermann <max@duempel.org> | 2014-01-07 21:39:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-01-09 09:05:58 +0100 |
commit | 322b0616322760dc162447563d8f4da7e024ca90 (patch) | |
tree | 2f87cb3ce061556161797aba9f57ee08de5b9e21 /src/PlaylistFile.cxx | |
parent | 43847f2244a34064af24704aac4cfad4a3c76f7d (diff) | |
download | mpd-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 '')
-rw-r--r-- | src/PlaylistFile.cxx | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index 3f9845166..0f84cc4eb 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -24,7 +24,7 @@ #include "PlaylistVector.hxx" #include "DatabasePlugin.hxx" #include "DatabaseGlue.hxx" -#include "Song.hxx" +#include "DetachedSong.hxx" #include "Mapper.hxx" #include "fs/TextFile.hxx" #include "ConfigGlobal.hxx" @@ -361,7 +361,7 @@ spl_remove_index(const char *utf8path, unsigned pos, Error &error) } bool -spl_append_song(const char *utf8path, const Song &song, Error &error) +spl_append_song(const char *utf8path, const DetachedSong &song, Error &error) { if (spl_map(error).IsNull()) return false; @@ -402,22 +402,21 @@ bool spl_append_uri(const char *url, const char *utf8file, Error &error) { if (uri_has_scheme(url)) { - Song *song = Song::NewRemote(url); - bool success = spl_append_song(utf8file, *song, error); - song->Free(); - return success; + return spl_append_song(utf8file, DetachedSong(url), + error); } else { const Database *db = GetDatabase(error); if (db == nullptr) return false; - Song *song = db->GetSong(url, error); - if (song == nullptr) + Song *tmp = db->GetSong(url, error); + if (tmp == nullptr) return false; - bool success = spl_append_song(utf8file, *song, error); - db->ReturnSong(song); - return success; + const DetachedSong song(*tmp); + db->ReturnSong(tmp); + + return spl_append_song(utf8file, song, error); } } |