tag_ape: simplified the apeItems array
Make "enum tag_type" the array index, and convert apeItems to a sparse array.
This commit is contained in:
parent
7cca55549b
commit
026bd15872
|
@ -25,24 +25,14 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static const char *const apeItems[7] = {
|
static const char *const ape_tag_names[] = {
|
||||||
"title",
|
[TAG_ITEM_TITLE] = "title",
|
||||||
"artist",
|
[TAG_ITEM_ARTIST] = "artist",
|
||||||
"album",
|
[TAG_ITEM_ALBUM] = "album",
|
||||||
"comment",
|
[TAG_ITEM_COMMENT] = "comment",
|
||||||
"genre",
|
[TAG_ITEM_GENRE] = "genre",
|
||||||
"track",
|
[TAG_ITEM_TRACK] = "track",
|
||||||
"year"
|
[TAG_ITEM_DATE] = "year"
|
||||||
};
|
|
||||||
|
|
||||||
static const int tagItems[7] = {
|
|
||||||
TAG_ITEM_TITLE,
|
|
||||||
TAG_ITEM_ARTIST,
|
|
||||||
TAG_ITEM_ALBUM,
|
|
||||||
TAG_ITEM_COMMENT,
|
|
||||||
TAG_ITEM_GENRE,
|
|
||||||
TAG_ITEM_TRACK,
|
|
||||||
TAG_ITEM_DATE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct tag *
|
static struct tag *
|
||||||
|
@ -53,12 +43,12 @@ tag_ape_import_item(struct tag *tag, unsigned long flags,
|
||||||
if ((flags & (0x3 << 1)) != 0)
|
if ((flags & (0x3 << 1)) != 0)
|
||||||
return tag;
|
return tag;
|
||||||
|
|
||||||
for (unsigned i = 0; i < 7; i++) {
|
for (unsigned i = 0; i < G_N_ELEMENTS(ape_tag_names); i++) {
|
||||||
if (g_ascii_strcasecmp(key, apeItems[i]) == 0) {
|
if (ape_tag_names[i] != NULL &&
|
||||||
|
g_ascii_strcasecmp(key, ape_tag_names[i]) == 0) {
|
||||||
if (tag == NULL)
|
if (tag == NULL)
|
||||||
tag = tag_new();
|
tag = tag_new();
|
||||||
tag_add_item_n(tag, tagItems[i],
|
tag_add_item_n(tag, i, value, value_length);
|
||||||
value, value_length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue