Commit 949916cb authored by Max Kellermann's avatar Max Kellermann

db/simple/Song: convert NewFrom() to constructor

parent 497d0908
......@@ -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<Song>(std::move(*detached_song),
directory);
song->audio_format = audio_format;
directory.AddSong(std::move(song));
......
......@@ -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<Song>(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
......
......@@ -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
......
......@@ -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<Song>(std::move(vtrack),
*contdir);
// shouldn't be necessary but it's there..
song->mtime = info.mtime;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment