From 7470a5f8eae3707481ff29960369b811271ff031 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Mon, 9 May 2022 20:10:37 +0300 Subject: [PATCH] store/fields: Use one MaxTermLength everywhere One should be enough! --- lib/message/mu-fields.cc | 3 --- lib/message/mu-fields.hh | 4 ++++ lib/mu-server.cc | 2 +- lib/mu-store.hh | 2 -- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/message/mu-fields.cc b/lib/message/mu-fields.cc index f1eb5413..31e690c1 100644 --- a/lib/message/mu-fields.cc +++ b/lib/message/mu-fields.cc @@ -22,9 +22,6 @@ using namespace Mu; -// Xapian does not like terms much longer than this -constexpr auto MaxTermLength = 240; - std::string Field::xapian_term(const std::string& s) const { diff --git a/lib/message/mu-fields.hh b/lib/message/mu-fields.hh index dafc52d8..b0151ff5 100644 --- a/lib/message/mu-fields.hh +++ b/lib/message/mu-fields.hh @@ -30,6 +30,10 @@ namespace Mu { +// Xapian does not like terms much longer than this +constexpr auto MaxTermLength = 240; +// http://article.gmane.org/gmane.comp.search.xapian.general/3656 */ + struct Field { /** * Field Ids. diff --git a/lib/mu-server.cc b/lib/mu-server.cc index 47985e68..71cf41a1 100644 --- a/lib/mu-server.cc +++ b/lib/mu-server.cc @@ -572,7 +572,7 @@ Server::Private::contacts_handler(const Parameters& params) static std::vector docids_for_msgid(const Store& store, const std::string& msgid, size_t max = 100) { - if (msgid.size() > Store::MaxTermLength) { + if (msgid.size() > MaxTermLength) { throw Error(Error::Code::InvalidArgument, "invalid message-id '%s'", msgid.c_str()); } diff --git a/lib/mu-store.hh b/lib/mu-store.hh index 2be4c1ac..262ec32f 100644 --- a/lib/mu-store.hh +++ b/lib/mu-store.hh @@ -43,8 +43,6 @@ public: using Id = Xapian::docid; /**< Id for a message in the store */ static constexpr Id InvalidId = 0; /**< Invalid store id */ - static constexpr size_t MaxTermLength = 240; /**< Maximum length of a term, - http://article.gmane.org/gmane.comp.search.xapian.general/3656 */ /** * Construct a store for an existing document database *