summaryrefslogtreecommitdiff
path: root/apps/tagcache.c
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2007-04-29 14:40:59 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2007-04-29 14:40:59 +0000
commitb1ff1ea3031664e07a574dc16ea46fe098bf185f (patch)
tree441e4ff43e4e83c62299586be5e06cdad1cb2d7c /apps/tagcache.c
parent9270ada23aed7222fa4468bdef8ff128db06f341 (diff)
downloadrockbox-b1ff1ea3031664e07a574dc16ea46fe098bf185f.zip
rockbox-b1ff1ea3031664e07a574dc16ea46fe098bf185f.tar.gz
rockbox-b1ff1ea3031664e07a574dc16ea46fe098bf185f.tar.bz2
rockbox-b1ff1ea3031664e07a574dc16ea46fe098bf185f.tar.xz
Improved speed when deleting tags and prevent remaining ghost entries with database loaded in ram.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13284 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index e51b120..e917d55 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -3073,7 +3073,7 @@ static bool delete_entry(long idx_id)
#ifdef HAVE_TC_RAMCACHE
/* At first mark the entry removed from ram cache. */
- if (hdr)
+ if (tc_stat.ramcache)
hdr->indices[idx_id].flag |= FLAG_DELETED;
#endif
@@ -3106,15 +3106,26 @@ static bool delete_entry(long idx_id)
lseek(fd, sizeof(struct master_header), SEEK_SET);
for (i = 0; i < myhdr.tch.entry_count; i++)
{
- if (ecread(fd, &idx, 1, index_entry_ec, tc_stat.econ)
- != sizeof(struct index_entry))
+ struct index_entry *idxp;
+
+#ifdef HAVE_TC_RAMCACHE
+ /* Use RAM DB if available for greater speed */
+ if (tc_stat.ramcache)
+ idxp = &hdr->indices[i];
+ else
+#endif
{
- logf("delete_entry(): read error #2");
- close(fd);
- return false;
+ if (ecread(fd, &idx, 1, index_entry_ec, tc_stat.econ)
+ != sizeof(struct index_entry))
+ {
+ logf("delete_entry(): read error #2");
+ close(fd);
+ return false;
+ }
+ idxp = &idx;
}
- if (idx.flag & FLAG_DELETED)
+ if (idxp->flag & FLAG_DELETED)
continue;
for (tag = 0; tag < TAG_COUNT; tag++)
@@ -3122,7 +3133,7 @@ static bool delete_entry(long idx_id)
if (tagcache_is_numeric_tag(tag))
continue;
- if (idx.tag_seek[tag] == myidx.tag_seek[tag])
+ if (idxp->tag_seek[tag] == myidx.tag_seek[tag])
in_use[tag]++;
}
}
@@ -3141,6 +3152,15 @@ static bool delete_entry(long idx_id)
continue;
}
+#ifdef HAVE_TC_RAMCACHE
+ /* Delete from ram. */
+ if (tc_stat.ramcache && tag != tag_filename)
+ {
+ struct tagfile_entry *tagentry = get_tag(&myidx, tag);
+ tagentry->tag_data[0] = '\0';
+ }
+#endif
+
/* Open the index file, which contains the tag names. */
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag);
fd = open(buf, O_RDWR);