aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbUtils.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-08 11:47:57 +0200
committerMax Kellermann <max@duempel.org>2008-09-08 11:47:57 +0200
commitf0e64ceb48c485baf32528bba44875885d384354 (patch)
treec9869f5a5dd25a7eb88791ca6aa95f7c0e77168c /src/dbUtils.c
parent2b8040b42524dad68ea85c45a4be25909a03eb5c (diff)
downloadmpd-f0e64ceb48c485baf32528bba44875885d384354.tar.gz
mpd-f0e64ceb48c485baf32528bba44875885d384354.tar.xz
mpd-f0e64ceb48c485baf32528bba44875885d384354.zip
use strset.h instead of tagTracker.h
With a large music database, the linear string collection in tagTracker.c becomes very slow. We implemented that in a quick'n'dirty fashion when we removed tree.c, and now we rewrite it using the fast hashed string set.
Diffstat (limited to 'src/dbUtils.c')
-rw-r--r--src/dbUtils.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/dbUtils.c b/src/dbUtils.c
index 9eb6aa46b..d204d7e1e 100644
--- a/src/dbUtils.c
+++ b/src/dbUtils.c
@@ -25,7 +25,7 @@
#include "song.h"
#include "song_print.h"
#include "tag.h"
-#include "tagTracker.h"
+#include "strset.h"
#include "log.h"
#include "storedPlaylist.h"
@@ -278,7 +278,8 @@ static void freeListCommandItem(ListCommandItem * item)
free(item);
}
-static void visitTag(struct client *client, Song * song, enum tag_type tagType)
+static void visitTag(struct client *client, struct strset *set,
+ Song * song, enum tag_type tagType)
{
int i;
struct tag *tag = song->tag;
@@ -293,7 +294,7 @@ static void visitTag(struct client *client, Song * song, enum tag_type tagType)
for (i = 0; i < tag->numOfItems; i++) {
if (tag->items[i]->type == tagType) {
- visitInTagTracker(tagType, tag->items[i]->value);
+ strset_add(set, tag->items[i]->value);
}
}
}
@@ -301,6 +302,7 @@ static void visitTag(struct client *client, Song * song, enum tag_type tagType)
struct list_tags_data {
struct client *client;
ListCommandItem *item;
+ struct strset *set;
};
static int listUniqueTagsInDirectory(Song * song, void *_data)
@@ -310,7 +312,7 @@ static int listUniqueTagsInDirectory(Song * song, void *_data)
if (tagItemsFoundAndMatches(song, item->numConditionals,
item->conditionals)) {
- visitTag(data->client, song, item->tagType);
+ visitTag(data->client, data->set, song, item->tagType);
}
return 0;
@@ -328,14 +330,23 @@ int listAllUniqueTags(struct client *client, int type, int numConditionals,
};
if (type >= 0 && type <= TAG_NUM_OF_ITEM_TYPES) {
- resetVisitedFlagsInTagTracker(type);
+ data.set = strset_new();
}
ret = traverseAllIn(NULL, listUniqueTagsInDirectory, NULL,
&data);
if (type >= 0 && type <= TAG_NUM_OF_ITEM_TYPES) {
- printVisitedInTagTracker(client, type);
+ const char *value;
+
+ strset_rewind(data.set);
+
+ while ((value = strset_next(data.set)) != NULL)
+ client_printf(client, "%s: %s\n",
+ mpdTagItemKeys[type],
+ value);
+
+ strset_free(data.set);
}
freeListCommandItem(item);