diff options
author | Max Kellermann <max@musicpd.org> | 2014-08-12 15:38:59 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-09-04 12:02:17 +0200 |
commit | f4d0bd82053c7d2bd97e22d713514f3177d4a706 (patch) | |
tree | ce45e3f055c6aca1119f1449f785f1f13a82ba30 /src/db | |
parent | 1bfede120aae0334a28ead8fa2733b8add7cb01d (diff) |
db/simple/Song: make "parent" a reference, not a pointer
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/plugins/simple/Directory.cxx | 6 | ||||
-rw-r--r-- | src/db/plugins/simple/Song.cxx | 10 | ||||
-rw-r--r-- | src/db/plugins/simple/Song.hxx | 5 | ||||
-rw-r--r-- | src/db/update/Editor.cxx | 4 | ||||
-rw-r--r-- | src/db/update/Walk.cxx | 2 |
5 files changed, 13 insertions, 14 deletions
diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx index 2c1a5eced..e3821e259 100644 --- a/src/db/plugins/simple/Directory.cxx +++ b/src/db/plugins/simple/Directory.cxx @@ -167,7 +167,7 @@ Directory::AddSong(SongPtr song) noexcept { assert(holding_db_lock()); assert(song != nullptr); - assert(song->parent == this); + assert(&song->parent == this); songs.push_back(*song.release()); } @@ -177,7 +177,7 @@ Directory::RemoveSong(Song *song) noexcept { assert(holding_db_lock()); assert(song != nullptr); - assert(song->parent == this); + assert(&song->parent == this); songs.erase(songs.iterator_to(*song)); } @@ -189,7 +189,7 @@ Directory::FindSong(const char *name_utf8) const noexcept assert(name_utf8 != nullptr); for (auto &song : songs) { - assert(song.parent == this); + assert(&song.parent == this); if (song.uri == name_utf8) return &song; diff --git a/src/db/plugins/simple/Song.cxx b/src/db/plugins/simple/Song.cxx index 586ea3ec8..fa3c48c00 100644 --- a/src/db/plugins/simple/Song.cxx +++ b/src/db/plugins/simple/Song.cxx @@ -26,7 +26,7 @@ inline Song::Song(StringView _uri, Directory &_parent) noexcept - :parent(&_parent), uri(_uri.data, _uri.size) + :parent(_parent), uri(_uri.data, _uri.size) { } @@ -56,10 +56,10 @@ Song::NewFile(const char *path, Directory &parent) noexcept std::string Song::GetURI() const noexcept { - if (parent->IsRoot()) + if (parent.IsRoot()) return uri; else { - const char *path = parent->GetPath(); + const char *path = parent.GetPath(); std::string result; result.reserve(strlen(path) + 1 + uri.length()); @@ -74,8 +74,8 @@ LightSong Song::Export() const noexcept { LightSong dest(uri.c_str(), tag); - if (!parent->IsRoot()) - dest.directory = parent->GetPath(); + if (!parent.IsRoot()) + dest.directory = parent.GetPath(); dest.mtime = mtime; dest.start_time = start_time; dest.end_time = end_time; diff --git a/src/db/plugins/simple/Song.hxx b/src/db/plugins/simple/Song.hxx index 7637b764e..75c67583b 100644 --- a/src/db/plugins/simple/Song.hxx +++ b/src/db/plugins/simple/Song.hxx @@ -60,10 +60,9 @@ struct Song { Tag tag; /** - * The #Directory that contains this song. Must be - * non-nullptr. + * The #Directory that contains this song. */ - Directory *const parent; + Directory &parent; /** * The time stamp of the last file modification. A negative diff --git a/src/db/update/Editor.cxx b/src/db/update/Editor.cxx index c2ee27847..a97c9cf36 100644 --- a/src/db/update/Editor.cxx +++ b/src/db/update/Editor.cxx @@ -29,7 +29,7 @@ void DatabaseEditor::DeleteSong(Directory &dir, Song *del) { - assert(del->parent == &dir); + assert(&del->parent == &dir); /* first, prevent traversers in main task from getting this */ dir.RemoveSong(del); @@ -65,7 +65,7 @@ DatabaseEditor::ClearDirectory(Directory &directory) }); directory.ForEachSongSafe([this, &directory](Song &song){ - assert(song.parent == &directory); + assert(&song.parent == &directory); DeleteSong(directory, &song); }); } diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 245c045d8..bb8a86bb4 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -79,7 +79,7 @@ UpdateWalk::RemoveExcludedFromDirectory(Directory &directory, }); directory.ForEachSongSafe([&](Song &song){ - assert(song.parent == &directory); + assert(&song.parent == &directory); const auto name_fs = AllocatedPath::FromUTF8(song.uri.c_str()); if (name_fs.IsNull() || exclude_list.Check(name_fs)) { |