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
This commit is contained in:
parent
b3a7f39c66
commit
6a0021cf20
1 changed files with 4 additions and 10 deletions
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue