aboutsummaryrefslogtreecommitdiffhomepage
path: root/database.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-10-25 00:25:59 -0700
committerGravatar Carl Worth <cworth@cworth.org>2009-10-25 00:31:20 -0700
commit1c2bac747e4da6cb8383aa3ad5e377af4cce603f (patch)
treea06db69dff18ed61d93d74ec1f4a6e2b4c652fdd /database.cc
parent5941b91a5eee61ae7d0f6c8f750df9187780e911 (diff)
Drop the storage of thread ID(s) in a value.
Now that we are iterating over the thread terms instead, we can drop this redundant storage (which should shrink our database a tiny bit).
Diffstat (limited to 'database.cc')
-rw-r--r--database.cc40
1 files changed, 24 insertions, 16 deletions
diff --git a/database.cc b/database.cc
index aaad7105..751e2d99 100644
--- a/database.cc
+++ b/database.cc
@@ -192,26 +192,34 @@ find_unique_document (notmuch_database_t *notmuch,
return NOTMUCH_PRIVATE_STATUS_SUCCESS;
}
+/* XXX: Should rewrite this to accept a notmuch_message_t* instead of
+ * a Xapian:Document and then we could just use
+ * notmuch_message_get_thread_ids instead of duplicating its logic
+ * here. */
static void
insert_thread_id (GHashTable *thread_ids, Xapian::Document doc)
{
string value_string;
- const char *value, *id, *comma;
-
- value_string = doc.get_value (NOTMUCH_VALUE_THREAD);
- value = value_string.c_str();
- if (strlen (value)) {
- id = value;
- while (*id) {
- comma = strchr (id, ',');
- if (comma == NULL)
- comma = id + strlen (id);
- g_hash_table_insert (thread_ids,
- strndup (id, comma - id), NULL);
- id = comma;
- if (*id)
- id++;
- }
+ Xapian::TermIterator i;
+ const char *prefix_str = _find_prefix ("thread");
+ char prefix;
+
+ assert (strlen (prefix_str) == 1);
+
+ prefix = *prefix_str;
+
+ i = doc.termlist_begin ();
+ i.skip_to (prefix_str);
+
+ while (1) {
+ if (i == doc.termlist_end ())
+ break;
+ value_string = *i;
+ if (value_string.empty () || value_string[0] != prefix)
+ break;
+ g_hash_table_insert (thread_ids,
+ strdup (value_string.c_str () + 1), NULL);
+ i++;
}
}