FS#12132 patch 3: Rename read_numeric_tag to find_tag, as it is indeed

used for nonnumeric tags as well.

Optimization for the nonnumeric case: Only numerics are ever updated,
so there's no need to scan the command queue for updates to nonnumeric
tags.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29979 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Hohmuth 2011-06-06 22:48:57 +00:00
parent 509d6a901d
commit 564a8ed1fd

View file

@ -770,10 +770,10 @@ static bool retrieve(struct tagcache_search *tcs, struct index_entry *idx,
#define COMMAND_QUEUE_IS_EMPTY (command_queue_ridx == command_queue_widx) #define COMMAND_QUEUE_IS_EMPTY (command_queue_ridx == command_queue_widx)
static long read_numeric_tag(int tag, int idx_id, const struct index_entry *idx) static long find_tag(int tag, int idx_id, const struct index_entry *idx)
{ {
#ifndef __PCTOOL__ #ifndef __PCTOOL__
if (! COMMAND_QUEUE_IS_EMPTY) if (! COMMAND_QUEUE_IS_EMPTY && TAGCACHE_IS_NUMERIC(tag))
{ {
/* Attempt to find tag data through store-to-load forwarding in /* Attempt to find tag data through store-to-load forwarding in
command queue */ command queue */
@ -801,7 +801,7 @@ static long read_numeric_tag(int tag, int idx_id, const struct index_entry *idx)
if (result >= 0) if (result >= 0)
{ {
logf("read_numeric_tag: " logf("find_tag: "
"Recovered tag %d value %lX from write queue", "Recovered tag %d value %lX from write queue",
tag, result); tag, result);
return result; return result;
@ -821,24 +821,24 @@ static long check_virtual_tags(int tag, int idx_id,
switch (tag) switch (tag)
{ {
case tag_virt_length_sec: case tag_virt_length_sec:
data = (read_numeric_tag(tag_length, idx_id, idx)/1000) % 60; data = (find_tag(tag_length, idx_id, idx)/1000) % 60;
break; break;
case tag_virt_length_min: case tag_virt_length_min:
data = (read_numeric_tag(tag_length, idx_id, idx)/1000) / 60; data = (find_tag(tag_length, idx_id, idx)/1000) / 60;
break; break;
case tag_virt_playtime_sec: case tag_virt_playtime_sec:
data = (read_numeric_tag(tag_playtime, idx_id, idx)/1000) % 60; data = (find_tag(tag_playtime, idx_id, idx)/1000) % 60;
break; break;
case tag_virt_playtime_min: case tag_virt_playtime_min:
data = (read_numeric_tag(tag_playtime, idx_id, idx)/1000) / 60; data = (find_tag(tag_playtime, idx_id, idx)/1000) / 60;
break; break;
case tag_virt_autoscore: case tag_virt_autoscore:
if (read_numeric_tag(tag_length, idx_id, idx) == 0 if (find_tag(tag_length, idx_id, idx) == 0
|| read_numeric_tag(tag_playcount, idx_id, idx) == 0) || find_tag(tag_playcount, idx_id, idx) == 0)
{ {
data = 0; data = 0;
} }
@ -854,23 +854,23 @@ static long check_virtual_tags(int tag, int idx_id,
autoscore = 100 * (alpha / playcout + beta / length / playcount) autoscore = 100 * (alpha / playcout + beta / length / playcount)
Both terms should be small enough to avoid any overflow Both terms should be small enough to avoid any overflow
*/ */
data = 100 * (read_numeric_tag(tag_playtime, idx_id, idx) data = 100 * (find_tag(tag_playtime, idx_id, idx)
/ read_numeric_tag(tag_length, idx_id, idx)) / find_tag(tag_length, idx_id, idx))
+ (100 * (read_numeric_tag(tag_playtime, idx_id, idx) + (100 * (find_tag(tag_playtime, idx_id, idx)
% read_numeric_tag(tag_length, idx_id, idx))) % find_tag(tag_length, idx_id, idx)))
/ read_numeric_tag(tag_length, idx_id, idx); / find_tag(tag_length, idx_id, idx);
data /= read_numeric_tag(tag_playcount, idx_id, idx); data /= find_tag(tag_playcount, idx_id, idx);
} }
break; break;
/* How many commits before the file has been added to the DB. */ /* How many commits before the file has been added to the DB. */
case tag_virt_entryage: case tag_virt_entryage:
data = current_tcmh.commitid data = current_tcmh.commitid
- read_numeric_tag(tag_commitid, idx_id, idx) - 1; - find_tag(tag_commitid, idx_id, idx) - 1;
break; break;
default: default:
data = read_numeric_tag(tag, idx_id, idx); data = find_tag(tag, idx_id, idx);
} }
return data; return data;