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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user