mu-document: Make sexp() lazy (optimization)

This makes queries where we don't need the sexp much faster; e.g.

before:
   mu find "a" --include-related  47,51s user 2,68s system 99% cpu 50,651 total
after:
  mu find "a" --include-related  7,12s user 1,97s system 87% cpu 10,363 total
This commit is contained in:
Dirk-Jan C. Binnema
2023-07-31 22:26:06 +03:00
parent 7c85b61944
commit 1018f0f0a1
2 changed files with 14 additions and 11 deletions

View File

@ -38,7 +38,7 @@ const Xapian::Document&
Document::xapian_document() const
{
if (dirty_sexp_) {
xdoc_.set_data(sexp_.to_string());
xdoc_.set_data(sexp().to_string());
dirty_sexp_ = false;
}
return xdoc_;
@ -47,7 +47,7 @@ Document::xapian_document() const
template<typename SexpType> void
Document::put_prop(const std::string& pname, SexpType&& val)
{
sexp_.put_props(pname, std::forward<SexpType>(val));
cached_sexp().put_props(pname, std::forward<SexpType>(val));
dirty_sexp_ = true;
}