aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-03 14:28:42 +0200
committerMax Kellermann <max@duempel.org>2008-10-03 14:28:42 +0200
commitb64329b9942d2315dd968264e92a51d63a135a77 (patch)
tree939157ba1a08ec3206bc1d5385337f410ec33a60
parent492c5295389440982412a58fd008b36df0537d16 (diff)
downloadmpd-b64329b9942d2315dd968264e92a51d63a135a77.tar.gz
mpd-b64329b9942d2315dd968264e92a51d63a135a77.tar.xz
mpd-b64329b9942d2315dd968264e92a51d63a135a77.zip
screen_search: array index is tag id
Save some bytes again: remove search_tag.id, make the array index equal to the tag id.
-rw-r--r--src/screen_search.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/screen_search.c b/src/screen_search.c
index b5b24964d..989ac7eaa 100644
--- a/src/screen_search.c
+++ b/src/screen_search.c
@@ -34,38 +34,33 @@
#include <glib.h>
#include <ncurses.h>
-typedef struct {
- int id;
+static const struct {
const char *name;
const char *localname;
-} search_tag_t;
-
-static search_tag_t search_tag[] = {
- { MPD_TAG_ITEM_ARTIST, "artist", N_("artist") },
- { MPD_TAG_ITEM_ALBUM, "album", N_("album") },
- { MPD_TAG_ITEM_TITLE, "title", N_("title") },
- { MPD_TAG_ITEM_TRACK, "track", N_("track") },
- { MPD_TAG_ITEM_NAME, "name", N_("name") },
- { MPD_TAG_ITEM_GENRE, "genre", N_("genre") },
- { MPD_TAG_ITEM_DATE, "date", N_("date") },
- { MPD_TAG_ITEM_COMPOSER, "composer", N_("composer") },
- { MPD_TAG_ITEM_PERFORMER, "performer", N_("performer") },
- { MPD_TAG_ITEM_COMMENT, "comment", N_("comment") },
- { MPD_TAG_ITEM_FILENAME, "filename", N_("file") },
- { -1, NULL, NULL }
+} search_tag[MPD_TAG_NUM_OF_ITEM_TYPES] = {
+ [MPD_TAG_ITEM_ARTIST] = { "artist", N_("artist") },
+ [MPD_TAG_ITEM_ALBUM] = { "album", N_("album") },
+ [MPD_TAG_ITEM_TITLE] = { "title", N_("title") },
+ [MPD_TAG_ITEM_TRACK] = { "track", N_("track") },
+ [MPD_TAG_ITEM_NAME] = { "name", N_("name") },
+ [MPD_TAG_ITEM_GENRE] = { "genre", N_("genre") },
+ [MPD_TAG_ITEM_DATE] = { "date", N_("date") },
+ [MPD_TAG_ITEM_COMPOSER] = { "composer", N_("composer") },
+ [MPD_TAG_ITEM_PERFORMER] = { "performer", N_("performer") },
+ [MPD_TAG_ITEM_COMMENT] = { "comment", N_("comment") },
+ [MPD_TAG_ITEM_FILENAME] = { "filename", N_("file") },
};
static int
search_get_tag_id(char *name)
{
- int i = 0;
+ unsigned i;
- while (search_tag[i].name) {
- if (strcasecmp(search_tag[i].name, name) == 0 ||
- strcasecmp(search_tag[i].localname, name) == 0)
- return search_tag[i].id;
- i++;
- }
+ for (i = 0; i < MPD_TAG_NUM_OF_ITEM_TYPES; ++i)
+ if (search_tag[i].name != NULL &&
+ (strcasecmp(search_tag[i].name, name) == 0 ||
+ strcasecmp(search_tag[i].localname, name) == 0))
+ return i;
return -1;
}