summaryrefslogtreecommitdiffstats
path: root/apps/tagcache.c
diff options
context:
space:
mode:
authorMichael Hohmuth <sideral@rockbox.org>2011-06-06 22:49:07 +0000
committerMichael Hohmuth <sideral@rockbox.org>2011-06-06 22:49:07 +0000
commit6a0021cf2044e2bc36883a63362cbc7657bf5fe0 (patch)
tree598af89209cabe3eeef3d0678871e5623b3f8331 /apps/tagcache.c
parentb3a7f39c66b0f983b5aa7b4c0846ce422f06a854 (diff)
downloadrockbox-6a0021cf2044e2bc36883a63362cbc7657bf5fe0.tar.gz
rockbox-6a0021cf2044e2bc36883a63362cbc7657bf5fe0.tar.bz2
rockbox-6a0021cf2044e2bc36883a63362cbc7657bf5fe0.zip
FS#12132 patch 5: check_clauses: Optimizations.
* There's no need to reset the buffer argument to check_against_clauses to 0 when it's not needed. We can always initialize str = buf and only change it on a RAM search hit. * Do not memset buffer to 0 -- it's sufficient to make sure the retrieved tag string is zero-terminated. * Factor out a call to check_virtual_tags from two branches of an if statement. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29981 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 629bf46aba..a3585feea5 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -993,28 +993,25 @@ static bool check_clauses(struct tagcache_search *tcs,
{
int seek;
char buf[256];
- char *str;
+ char *str = buf;
struct tagcache_search_clause *clause = clauses[i];
if (clause->type == clause_logical_or)
break; /* all conditions before logical-or satisfied --
stop processing clauses */
-#ifdef HAVE_TC_RAMCACHE
- str = NULL;
+ seek = check_virtual_tags(clause->tag, tcs->idx_id, idx);
+#ifdef HAVE_TC_RAMCACHE
if (tcs->ramsearch)
{
struct tagfile_entry *tfe;
- seek = check_virtual_tags(clause->tag, tcs->idx_id, idx);
-
if (!TAGCACHE_IS_NUMERIC(clause->tag))
{
if (clause->tag == tag_filename)
{
retrieve(tcs, idx, tag_filename, buf, sizeof buf);
- str = buf;
}
else
{
@@ -1027,11 +1024,7 @@ static bool check_clauses(struct tagcache_search *tcs,
#endif
{
struct tagfile_entry tfe;
- str = buf;
- seek = check_virtual_tags(clause->tag, tcs->idx_id, idx);
-
- memset(buf, 0, sizeof buf);
if (!TAGCACHE_IS_NUMERIC(clause->tag))
{
int fd = tcs->idxfd[clause->tag];
@@ -1044,6 +1037,7 @@ static bool check_clauses(struct tagcache_search *tcs,
}
read(fd, str, tfe.tag_length);
+ str[tfe.tag_length] = '\0';
/* Check if entry has been deleted. */
if (str[0] == '\0')