mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-02-17 23:53:15 +01:00
lib: define specialized get_thread_id for use in thread subquery
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
This commit is contained in:
parent
60fcec82d2
commit
f0131af6c5
3 changed files with 22 additions and 1 deletions
|
@ -318,6 +318,23 @@ _notmuch_message_get_term (notmuch_message_t *message,
|
||||||
return value;
|
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
|
static void
|
||||||
_notmuch_message_ensure_metadata (notmuch_message_t *message, void *field)
|
_notmuch_message_ensure_metadata (notmuch_message_t *message, void *field)
|
||||||
{
|
{
|
||||||
|
|
|
@ -537,6 +537,10 @@ _notmuch_message_database (notmuch_message_t *message);
|
||||||
|
|
||||||
void
|
void
|
||||||
_notmuch_message_remove_unprefixed_terms (notmuch_message_t *message);
|
_notmuch_message_remove_unprefixed_terms (notmuch_message_t *message);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
_notmuch_message_get_thread_id_only(notmuch_message_t *message);
|
||||||
|
|
||||||
/* sha1.c */
|
/* sha1.c */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
|
@ -52,7 +52,7 @@ ThreadFieldProcessor::operator() (const std::string & str)
|
||||||
std::string term = thread_prefix;
|
std::string term = thread_prefix;
|
||||||
notmuch_message_t *message;
|
notmuch_message_t *message;
|
||||||
message = notmuch_messages_get (messages);
|
message = notmuch_messages_get (messages);
|
||||||
term += notmuch_message_get_thread_id (message);
|
term += _notmuch_message_get_thread_id_only (message);
|
||||||
terms.insert (term);
|
terms.insert (term);
|
||||||
}
|
}
|
||||||
return Xapian::Query (Xapian::Query::OP_OR, terms.begin (), terms.end ());
|
return Xapian::Query (Xapian::Query::OP_OR, terms.begin (), terms.end ());
|
||||||
|
|
Loading…
Add table
Reference in a new issue