diff options
author | Max Kellermann <max@duempel.org> | 2012-02-11 10:34:21 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-02-11 12:37:24 +0100 |
commit | 767ade02f4af8cdb6b7de293d0bd433bc7fd24cf (patch) | |
tree | 657ef4bf4fc49524007cb6e26d214edb04585ff3 /src/tag_table.h | |
parent | 6e05071a47cd2f496f49d08823ace6fdcb1f79cd (diff) |
tag_table: convert to a struct
The struct is smaller because it is sparse. Its traversal is also
more efficient.
Diffstat (limited to 'src/tag_table.h')
-rw-r--r-- | src/tag_table.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/tag_table.h b/src/tag_table.h index 367a3de5..ecb3805d 100644 --- a/src/tag_table.h +++ b/src/tag_table.h @@ -24,18 +24,24 @@ #include <glib.h> +struct tag_table { + const char *name; + + enum tag_type type; +}; + /** * Looks up a string in a tag translation table (case insensitive). * Returns TAG_NUM_OF_ITEM_TYPES if the specified name was not found * in the table. */ +G_GNUC_PURE static inline enum tag_type -tag_table_lookup(const char *const* table, const char *name) +tag_table_lookup_i(const struct tag_table *table, const char *name) { - for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++) - if (table[i] != NULL && - g_ascii_strcasecmp(name, table[i]) == 0) - return (enum tag_type)i; + for (; table->name != NULL; ++table) + if (g_ascii_strcasecmp(name, table->name) == 0) + return table->type; return TAG_NUM_OF_ITEM_TYPES; } |