aboutsummaryrefslogtreecommitdiffstats
path: root/libibex/wordindex.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-10-24 10:33:08 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-10-24 10:33:08 +0800
commit04780422995146b73e64c37ad79f42516c77d52e (patch)
tree12663cb6be8533f50e7820563f1b705f2c5f6231 /libibex/wordindex.c
parentbdb308067c223640c2c14ebd92205e0ae1d20326 (diff)
downloadgsoc2013-evolution-04780422995146b73e64c37ad79f42516c77d52e.tar.gz
gsoc2013-evolution-04780422995146b73e64c37ad79f42516c77d52e.tar.zst
gsoc2013-evolution-04780422995146b73e64c37ad79f42516c77d52e.zip
Dumps the contents of indexs.
2000-10-24 Not Zed <NotZed@HelixCode.com> * dumpindex.c: Dumps the contents of indexs. * hash.c (ibex_hash_dump_rec): Also print the word count. * wordindex.c (unindex_name): Cross-check the cache as well. svn path=/trunk/; revision=6139
Diffstat (limited to 'libibex/wordindex.c')
-rw-r--r--libibex/wordindex.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/libibex/wordindex.c b/libibex/wordindex.c
index da25389b27..62e8859e15 100644
--- a/libibex/wordindex.c
+++ b/libibex/wordindex.c
@@ -145,6 +145,8 @@ static void unindex_name(struct _IBEXWord *idx, const char *name)
int i;
nameid_t nameid, wordid;
blockid_t nameblock, wordblock, newblock, nametail, wordtail, newtail;
+ char *word;
+ struct _wordcache *cache;
d(printf("unindexing %s\n", name));
@@ -168,7 +170,34 @@ static void unindex_name(struct _IBEXWord *idx, const char *name)
if (newblock != wordblock || newtail != wordtail)
idx->wordindex->klass->set_data(idx->wordindex, wordid, newblock, newtail);
- /* FIXME: check cache as well */
+ /* now check the cache as well */
+ word = idx->nameindex->klass->get_key(idx->wordindex, wordid, NULL);
+ if (word) {
+ cache = g_hash_table_lookup(idx->wordcache, word);
+ if (cache) {
+ /* its there, update our head/tail pointers */
+ cache->wordblock = newblock;
+ cache->wordtail = newtail;
+
+ /* now check that we have a data entry in it */
+ if (cache->filealloc == 0 && cache->filecount == 1) {
+ if (cache->file.file0 == nameid) {
+ cache->filecount = 0;
+ }
+ } else {
+ int j;
+
+ for (j=0;j<cache->filecount;j++) {
+ if (cache->file.files[j] == nameid) {
+ cache->file.files[j] = cache->file.files[cache->filecount-1];
+ cache->filecount--;
+ break;
+ }
+ }
+ }
+ }
+ g_free(word);
+ }
}
g_array_free(words, TRUE);