aboutsummaryrefslogtreecommitdiffstats
path: root/src/update_walk.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-01-24 18:20:58 +0100
committerMax Kellermann <max@duempel.org>2012-01-24 20:49:53 +0100
commitd99f074eb73d5228528961a78c13419c2c4c26ae (patch)
tree26749b6a0feb81d1bda7d0e1511d38ba1716cfcd /src/update_walk.c
parenta989140a0767823fcec4ef745b639b92838413f9 (diff)
downloadmpd-d99f074eb73d5228528961a78c13419c2c4c26ae.tar.gz
mpd-d99f074eb73d5228528961a78c13419c2c4c26ae.tar.xz
mpd-d99f074eb73d5228528961a78c13419c2c4c26ae.zip
directory: replace dirvec with doubly linked list
Random access is not needed, and a linked list is easier to manage: we don't need to (re-)allocate the pointer array.
Diffstat (limited to '')
-rw-r--r--src/update_walk.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/update_walk.c b/src/update_walk.c
index 332f62bbb..1c0bb30b6 100644
--- a/src/update_walk.c
+++ b/src/update_walk.c
@@ -121,12 +121,9 @@ delete_directory(struct directory *directory);
static void
clear_directory(struct directory *directory)
{
- int i;
-
- for (i = directory->children.nr; --i >= 0;)
- delete_directory(directory->children.base[i]);
-
- assert(directory->children.nr == 0);
+ struct directory *child, *n;
+ directory_for_each_child_safe(child, n, directory)
+ delete_directory(child);
songvec_for_each(&directory->songs, delete_each_song, directory);
}
@@ -185,11 +182,8 @@ static void
remove_excluded_from_directory(struct directory *directory,
GSList *exclude_list)
{
- int i;
- struct dirvec *dv = &directory->children;
-
- for (i = dv->nr; --i >= 0; ) {
- struct directory *child = dv->base[i];
+ struct directory *child, *n;
+ directory_for_each_child_safe(child, n, directory) {
char *name_fs = utf8_to_fs_charset(directory_get_name(child));
if (exclude_list_check(exclude_list, name_fs)) {
@@ -263,14 +257,12 @@ directory_child_is_regular(const struct directory *directory,
static void
removeDeletedFromDirectory(struct directory *directory)
{
- int i;
- struct dirvec *dv = &directory->children;
-
- for (i = dv->nr; --i >= 0; ) {
- if (directory_exists(dv->base[i]))
+ struct directory *child, *n;
+ directory_for_each_child_safe(child, n, directory) {
+ if (directory_exists(child))
continue;
- delete_directory(dv->base[i]);
+ delete_directory(child);
modified = true;
}