diff options
author | Max Kellermann <max@duempel.org> | 2014-06-10 21:15:40 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-06-16 18:39:16 +0200 |
commit | 3ca0a39a357d9be9c85de4892ac02716f8af2ae8 (patch) | |
tree | 88c87573974f6609a1dc68cf20e5901600613280 /src/db/update | |
parent | 52594e64d0f48eb83c9bf54eb1ac95a6de881829 (diff) | |
download | mpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.tar.gz mpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.tar.xz mpd-3ca0a39a357d9be9c85de4892ac02716f8af2ae8.zip |
db/simple: use class boost::intrusive::list
Remove the C list_head library and use type-safe C++ instead.
Diffstat (limited to 'src/db/update')
-rw-r--r-- | src/db/update/Editor.cxx | 17 | ||||
-rw-r--r-- | src/db/update/Walk.cxx | 61 |
2 files changed, 37 insertions, 41 deletions
diff --git a/src/db/update/Editor.cxx b/src/db/update/Editor.cxx index c3c1a23d6..4136ccdad 100644 --- a/src/db/update/Editor.cxx +++ b/src/db/update/Editor.cxx @@ -64,15 +64,14 @@ DatabaseEditor::LockDeleteSong(Directory &parent, Song *song) inline void DatabaseEditor::ClearDirectory(Directory &directory) { - Directory *child, *n; - directory_for_each_child_safe(child, n, directory) - DeleteDirectory(child); - - Song *song, *ns; - directory_for_each_song_safe(song, ns, directory) { - assert(song->parent == &directory); - DeleteSong(directory, song); - } + directory.ForEachChildSafe([this](Directory &child){ + DeleteDirectory(&child); + }); + + directory.ForEachSongSafe([this, &directory](Song &song){ + assert(song.parent == &directory); + DeleteSong(directory, &song); + }); } void diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index c329865ff..afb67ab29 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -80,26 +80,25 @@ UpdateWalk::RemoveExcludedFromDirectory(Directory &directory, { db_lock(); - Directory *child, *n; - directory_for_each_child_safe(child, n, directory) { - const auto name_fs = AllocatedPath::FromUTF8(child->GetName()); + directory.ForEachChildSafe([&](Directory &child){ + const auto name_fs = + AllocatedPath::FromUTF8(child.GetName()); - if (name_fs.IsNull() || exclude_list.Check(name_fs)) { - editor.DeleteDirectory(child); - modified = true; - } - } + if (name_fs.IsNull() || exclude_list.Check(name_fs)) { + editor.DeleteDirectory(&child); + modified = true; + } + }); - Song *song, *ns; - directory_for_each_song_safe(song, ns, directory) { - assert(song->parent == &directory); + directory.ForEachSongSafe([&](Song &song){ + assert(song.parent == &directory); - const auto name_fs = AllocatedPath::FromUTF8(song->uri); - if (name_fs.IsNull() || exclude_list.Check(name_fs)) { - editor.DeleteSong(directory, song); - modified = true; - } - } + const auto name_fs = AllocatedPath::FromUTF8(song.uri); + if (name_fs.IsNull() || exclude_list.Check(name_fs)) { + editor.DeleteSong(directory, &song); + modified = true; + } + }); db_unlock(); } @@ -107,25 +106,23 @@ UpdateWalk::RemoveExcludedFromDirectory(Directory &directory, inline void UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) { - Directory *child, *n; - directory_for_each_child_safe(child, n, directory) { - if (DirectoryExists(storage, *child)) - continue; + directory.ForEachChildSafe([&](Directory &child){ + if (DirectoryExists(storage, child)) + return; - editor.LockDeleteDirectory(child); + editor.LockDeleteDirectory(&child); - modified = true; - } + modified = true; + }); - Song *song, *ns; - directory_for_each_song_safe(song, ns, directory) { - if (!directory_child_is_regular(storage, directory, - song->uri)) { - editor.LockDeleteSong(directory, song); + directory.ForEachSongSafe([&](Song &song){ + if (!directory_child_is_regular(storage, directory, + song.uri)) { + editor.LockDeleteSong(directory, &song); - modified = true; - } - } + modified = true; + } + }); for (auto i = directory.playlists.begin(), end = directory.playlists.end(); |