summaryrefslogtreecommitdiffstats
path: root/apps/tagcache.c
diff options
context:
space:
mode:
authorAndrew Mahone <andrew.mahone@gmail.com>2009-06-06 00:00:58 +0000
committerAndrew Mahone <andrew.mahone@gmail.com>2009-06-06 00:00:58 +0000
commitde7c5711c5d67e7e69386d6e35e42c8ce15de69b (patch)
tree22f58338387ae6ac662e43fe83ef60105f97d627 /apps/tagcache.c
parentfe72c890a76c1f227ef749adbdcf964bb166d74c (diff)
downloadrockbox-de7c5711c5d67e7e69386d6e35e42c8ce15de69b.tar.gz
rockbox-de7c5711c5d67e7e69386d6e35e42c8ce15de69b.zip
Add a system-wide BIT_N macro, implemented via an LUT on SH, and use it in the TAGCACHE_IS_* macros in place of per-set LUTs, removing duplication of data between those LUTs and the mask values used on other targets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21195 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c30
1 files changed, 5 insertions, 25 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 3d0ab7fbd3..afe55f18a2 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -108,29 +108,10 @@ static long tempbuf_left; /* Buffer space left. */
static long tempbuf_pos;
#define SORTED_TAGS_COUNT 8
-#ifdef CPU_SH /* SH lacks a variable shift instruction */
-/* Numeric tags (we can use these tags with conditional clauses). */
-const char tagcache_numeric_tags[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
- 1, 1, 1, 1, 1 };
-
-/* Uniqued tags (we can use these tags with filters and conditional clauses). */
-static const char tagcache_unique_tags[] = { 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0 };
-
-/* Tags we want to get sorted (loaded to the tempbuf). */
-static const char tagcache_sorted_tags[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0 };
-
-#define TAGCACHE_IS_UNIQUE(tag) ((bool)tagcache_unique_tags[tag])
-#define TAGCACHE_IS_SORTED(tag) ((bool)tagcache_sorted_tags[tag])
-
-#else
-#define TAGCACHE_IS_UNIQUE(tag) ((1LU << tag) & TAGCACHE_UNIQUE_TAGS)
-#define TAGCACHE_IS_SORTED(tag) ((1LU << tag) & TAGCACHE_SORTED_TAGS)
-
+#define TAGCACHE_IS_UNIQUE(tag) (BIT_N(tag) & TAGCACHE_UNIQUE_TAGS)
+#define TAGCACHE_IS_SORTED(tag) (BIT_N(tag) & TAGCACHE_SORTED_TAGS)
+#define TAGCACHE_IS_NUMERIC_OR_NONUNIQUE(tag) \
+ (BIT_N(tag) & (TAGCACHE_NUMERIC_TAGS | ~TAGCACHE_UNIQUE_TAGS))
/* Tags we want to get sorted (loaded to the tempbuf). */
#define TAGCACHE_SORTED_TAGS ((1LU << tag_artist) | (1LU << tag_album) | \
(1LU << tag_genre) | (1LU << tag_composer) | (1LU << tag_comment) | \
@@ -140,7 +121,6 @@ static const char tagcache_sorted_tags[] = { 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0,
#define TAGCACHE_UNIQUE_TAGS ((1LU << tag_artist) | (1LU << tag_album) | \
(1LU << tag_genre) | (1LU << tag_composer) | (1LU << tag_comment) | \
(1LU << tag_albumartist) | (1LU << tag_grouping))
-#endif
/* String presentation of the tags defined in tagcache.h. Must be in correct order! */
static const char *tags_str[] = { "artist", "album", "genre", "title",
@@ -1248,7 +1228,7 @@ bool tagcache_search_add_filter(struct tagcache_search *tcs,
if (tcs->filter_count == TAGCACHE_MAX_FILTERS)
return false;
- if (!TAGCACHE_IS_UNIQUE(tag) || TAGCACHE_IS_NUMERIC(tag))
+ if (TAGCACHE_IS_NUMERIC_OR_NONUNIQUE(tag))
return false;
tcs->filter_tag[tcs->filter_count] = tag;