aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-19 18:04:42 +0200
committerMax Kellermann <max@duempel.org>2009-07-19 18:04:42 +0200
commitc5ec035fb4a533ebd9f8c69b085604560d2a5487 (patch)
tree4666788a73cdd7604871a02b8241ef58e686a20e /src
parent5e2f98fdad1b4a552fd872c643f5584267a40dcc (diff)
downloadmpd-c5ec035fb4a533ebd9f8c69b085604560d2a5487.tar.gz
mpd-c5ec035fb4a533ebd9f8c69b085604560d2a5487.tar.xz
mpd-c5ec035fb4a533ebd9f8c69b085604560d2a5487.zip
tag_ape: simplified the apeItems array
Make "enum tag_type" the array index, and convert apeItems to a sparse array.
Diffstat (limited to 'src')
-rw-r--r--src/tag_ape.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/tag_ape.c b/src/tag_ape.c
index 999e045eb..4c3f4cf16 100644
--- a/src/tag_ape.c
+++ b/src/tag_ape.c
@@ -24,24 +24,14 @@
#include <stdio.h>
-static const char *const apeItems[7] = {
- "title",
- "artist",
- "album",
- "comment",
- "genre",
- "track",
- "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 const char *const ape_tag_names[] = {
+ [TAG_ITEM_TITLE] = "title",
+ [TAG_ITEM_ARTIST] = "artist",
+ [TAG_ITEM_ALBUM] = "album",
+ [TAG_ITEM_COMMENT] = "comment",
+ [TAG_ITEM_GENRE] = "genre",
+ [TAG_ITEM_TRACK] = "track",
+ [TAG_ITEM_DATE] = "year"
};
static struct tag *
@@ -52,12 +42,12 @@ tag_ape_import_item(struct tag *tag, unsigned long flags,
if ((flags & (0x3 << 1)) != 0)
return tag;
- for (unsigned i = 0; i < 7; i++) {
- if (g_ascii_strcasecmp(key, apeItems[i]) == 0) {
+ for (unsigned i = 0; i < G_N_ELEMENTS(ape_tag_names); i++) {
+ if (ape_tag_names[i] != NULL &&
+ g_ascii_strcasecmp(key, ape_tag_names[i]) == 0) {
if (tag == NULL)
tag = tag_new();
- tag_add_item_n(tag, tagItems[i],
- value, value_length);
+ tag_add_item_n(tag, i, value, value_length);
}
}