From 949916cba17a881338ed6753634b0e14528075bd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 4 Sep 2019 11:36:33 +0200 Subject: [PATCH] db/simple/Song: convert NewFrom() to constructor --- src/db/plugins/simple/DirectorySave.cxx | 4 ++-- src/db/plugins/simple/Song.cxx | 21 +++++++-------------- src/db/plugins/simple/Song.hxx | 2 +- src/db/update/Container.cxx | 3 ++- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/db/plugins/simple/DirectorySave.cxx b/src/db/plugins/simple/DirectorySave.cxx index 2d5e07d7c..753e0e1dc 100644 --- a/src/db/plugins/simple/DirectorySave.cxx +++ b/src/db/plugins/simple/DirectorySave.cxx @@ -165,8 +165,8 @@ directory_load(TextFile &file, Directory &directory) auto detached_song = song_load(file, name, &audio_format); - auto song = Song::NewFrom(std::move(*detached_song), - directory); + auto song = std::make_unique(std::move(*detached_song), + directory); song->audio_format = audio_format; directory.AddSong(std::move(song)); diff --git a/src/db/plugins/simple/Song.cxx b/src/db/plugins/simple/Song.cxx index e46398fa1..94fec6811 100644 --- a/src/db/plugins/simple/Song.cxx +++ b/src/db/plugins/simple/Song.cxx @@ -31,21 +31,14 @@ Song::Song(StringView _uri, Directory &_parent) noexcept { } -static SongPtr -song_alloc(StringView uri, Directory &parent) noexcept +Song::Song(DetachedSong &&other, Directory &_parent) noexcept + :tag(std::move(other.WritableTag())), + parent(_parent), + mtime(other.GetLastModified()), + start_time(other.GetStartTime()), + end_time(other.GetEndTime()), + uri(other.GetURI()) { - return std::make_unique(uri, parent); -} - -SongPtr -Song::NewFrom(DetachedSong &&other, Directory &parent) noexcept -{ - SongPtr song(song_alloc(other.GetURI(), parent)); - song->tag = std::move(other.WritableTag()); - song->mtime = other.GetLastModified(); - song->start_time = other.GetStartTime(); - song->end_time = other.GetEndTime(); - return song; } std::string diff --git a/src/db/plugins/simple/Song.hxx b/src/db/plugins/simple/Song.hxx index deeae85ef..9884d5922 100644 --- a/src/db/plugins/simple/Song.hxx +++ b/src/db/plugins/simple/Song.hxx @@ -99,7 +99,7 @@ struct Song { Song(StringView _uri, Directory &parent) noexcept; - static SongPtr NewFrom(DetachedSong &&other, Directory &parent) noexcept; + Song(DetachedSong &&other, Directory &_parent) noexcept; /** * allocate a new song structure with a local file name and attempt to diff --git a/src/db/update/Container.cxx b/src/db/update/Container.cxx index 651a10bee..562ea715c 100644 --- a/src/db/update/Container.cxx +++ b/src/db/update/Container.cxx @@ -69,7 +69,8 @@ UpdateWalk::UpdateContainerFile(Directory &directory, } for (auto &vtrack : v) { - auto song = Song::NewFrom(std::move(vtrack), *contdir); + auto song = std::make_unique(std::move(vtrack), + *contdir); // shouldn't be necessary but it's there.. song->mtime = info.mtime;