message/field: cache the message's sexp

Keep it in the store; much faster than generating on the fly.
This commit is contained in:
Dirk-Jan C. Binnema
2022-05-01 01:13:17 +03:00
parent 263e122a13
commit fea596ae3b
7 changed files with 90 additions and 49 deletions

View File

@ -344,6 +344,9 @@ Store::add_message(Message& msg, bool use_transaction)
if (auto&& res = msg.set_maildir(mdir.value()); !res)
return Err(res.error());
/* now, we're done with all the fields; generate the sexp string for this
* message */
msg.update_cached_sexp();
std::lock_guard guard{priv_->lock_};
@ -374,8 +377,12 @@ Store::add_message(Message& msg, bool use_transaction)
bool
Store::update_message(const Message& msg, unsigned docid)
Store::update_message(Message& msg, unsigned docid)
{
msg.update_cached_sexp();
std::lock_guard guard{priv_->lock_};
return xapian_try(
[&]{
priv_->writable_db().replace_document(