diff options
author | Michael Hohmuth <sideral@rockbox.org> | 2011-06-06 22:49:07 +0000 |
---|---|---|
committer | Michael Hohmuth <sideral@rockbox.org> | 2011-06-06 22:49:07 +0000 |
commit | 6a0021cf2044e2bc36883a63362cbc7657bf5fe0 (patch) | |
tree | 598af89209cabe3eeef3d0678871e5623b3f8331 /apps | |
parent | b3a7f39c66b0f983b5aa7b4c0846ce422f06a854 (diff) | |
download | rockbox-6a0021cf2044e2bc36883a63362cbc7657bf5fe0.tar.gz 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')
-rw-r--r-- | apps/tagcache.c | 14 |
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, | |||
993 | { | 993 | { |
994 | int seek; | 994 | int seek; |
995 | char buf[256]; | 995 | char buf[256]; |
996 | char *str; | 996 | char *str = buf; |
997 | struct tagcache_search_clause *clause = clauses[i]; | 997 | struct tagcache_search_clause *clause = clauses[i]; |
998 | 998 | ||
999 | if (clause->type == clause_logical_or) | 999 | if (clause->type == clause_logical_or) |
1000 | break; /* all conditions before logical-or satisfied -- | 1000 | break; /* all conditions before logical-or satisfied -- |
1001 | stop processing clauses */ | 1001 | stop processing clauses */ |
1002 | 1002 | ||
1003 | #ifdef HAVE_TC_RAMCACHE | 1003 | seek = check_virtual_tags(clause->tag, tcs->idx_id, idx); |
1004 | str = NULL; | ||
1005 | 1004 | ||
1005 | #ifdef HAVE_TC_RAMCACHE | ||
1006 | if (tcs->ramsearch) | 1006 | if (tcs->ramsearch) |
1007 | { | 1007 | { |
1008 | struct tagfile_entry *tfe; | 1008 | struct tagfile_entry *tfe; |
1009 | 1009 | ||
1010 | seek = check_virtual_tags(clause->tag, tcs->idx_id, idx); | ||
1011 | |||
1012 | if (!TAGCACHE_IS_NUMERIC(clause->tag)) | 1010 | if (!TAGCACHE_IS_NUMERIC(clause->tag)) |
1013 | { | 1011 | { |
1014 | if (clause->tag == tag_filename) | 1012 | if (clause->tag == tag_filename) |
1015 | { | 1013 | { |
1016 | retrieve(tcs, idx, tag_filename, buf, sizeof buf); | 1014 | retrieve(tcs, idx, tag_filename, buf, sizeof buf); |
1017 | str = buf; | ||
1018 | } | 1015 | } |
1019 | else | 1016 | else |
1020 | { | 1017 | { |
@@ -1027,11 +1024,7 @@ static bool check_clauses(struct tagcache_search *tcs, | |||
1027 | #endif | 1024 | #endif |
1028 | { | 1025 | { |
1029 | struct tagfile_entry tfe; | 1026 | struct tagfile_entry tfe; |
1030 | str = buf; | ||
1031 | 1027 | ||
1032 | seek = check_virtual_tags(clause->tag, tcs->idx_id, idx); | ||
1033 | |||
1034 | memset(buf, 0, sizeof buf); | ||
1035 | if (!TAGCACHE_IS_NUMERIC(clause->tag)) | 1028 | if (!TAGCACHE_IS_NUMERIC(clause->tag)) |
1036 | { | 1029 | { |
1037 | int fd = tcs->idxfd[clause->tag]; | 1030 | int fd = tcs->idxfd[clause->tag]; |
@@ -1044,6 +1037,7 @@ static bool check_clauses(struct tagcache_search *tcs, | |||
1044 | } | 1037 | } |
1045 | 1038 | ||
1046 | read(fd, str, tfe.tag_length); | 1039 | read(fd, str, tfe.tag_length); |
1040 | str[tfe.tag_length] = '\0'; | ||
1047 | 1041 | ||
1048 | /* Check if entry has been deleted. */ | 1042 | /* Check if entry has been deleted. */ |
1049 | if (str[0] == '\0') | 1043 | if (str[0] == '\0') |