]> git.notmuchmail.org Git - notmuch/commitdiff
lib: define specialized get_thread_id for use in thread subquery
authorDavid Bremner <david@tethera.net>
Sun, 28 Jan 2018 02:50:42 +0000 (22:50 -0400)
committerDavid Bremner <david@tethera.net>
Mon, 7 May 2018 11:42:53 +0000 (08:42 -0300)
The observation is that we are only using the messages to get there
thread_id, which is kindof a pessimal access pattern for the current
notmuch_message_get_thread_id

lib/message.cc
lib/notmuch-private.h
lib/thread-fp.cc

index d5db89b6606c7da011c2a80c5ce460f769f32650..b2067076effb9981c56a16ffdbd2ca4fdbe1c849 100644 (file)
@@ -318,6 +318,23 @@ _notmuch_message_get_term (notmuch_message_t *message,
     return value;
 }
 
+/*
+ * For special applications where we only want the thread id, reading
+ * in all metadata is a heavy I/O penalty.
+ */
+const char *
+_notmuch_message_get_thread_id_only (notmuch_message_t *message)
+{
+
+    Xapian::TermIterator i = message->doc.termlist_begin ();
+    Xapian::TermIterator end = message->doc.termlist_end ();
+
+    message->thread_id = _notmuch_message_get_term (message, i, end,
+                                                   _find_prefix ("thread"));
+    return message->thread_id;
+}
+
+
 static void
 _notmuch_message_ensure_metadata (notmuch_message_t *message, void *field)
 {
index 1093429cfc77026289f49754c7ea5c84330c71e6..4598577f3bc42e99a1e3bb4c120371de0df4becb 100644 (file)
@@ -537,6 +537,10 @@ _notmuch_message_database (notmuch_message_t *message);
 
 void
 _notmuch_message_remove_unprefixed_terms (notmuch_message_t *message);
+
+const char *
+_notmuch_message_get_thread_id_only(notmuch_message_t *message);
+
 /* sha1.c */
 
 char *
index 75339ffa79210ebca5192547e16bbcea6179faf8..7327700653bcab8ead048b55257617dfe9f52bc3 100644 (file)
@@ -52,7 +52,7 @@ ThreadFieldProcessor::operator() (const std::string & str)
                std::string term = thread_prefix;
                notmuch_message_t *message;
                message = notmuch_messages_get (messages);
-               term += notmuch_message_get_thread_id (message);
+               term += _notmuch_message_get_thread_id_only (message);
                terms.insert (term);
            }
            return Xapian::Query (Xapian::Query::OP_OR, terms.begin (), terms.end ());