Commit 9e76aebc authored by Volker Krause's avatar Volker Krause

Load the extractor repository only once

Rather than once per plugin instance. It's less of an issue now that we are
no longer parsing all the declarative extraction rules but just the minimal
extractor meta data, but it's still two file system searches we can avoid.
parent 9abba04c
......@@ -28,6 +28,19 @@
#include <QJsonDocument>
std::weak_ptr<ExtractorRepository> SemanticProcessor::s_repository;
m_repository = s_repository.lock();
if (!m_repository) {
m_repository.reset(new ExtractorRepository);
s_repository = m_repository;
SemanticProcessor::~SemanticProcessor() = default;
MimeTreeParser::MessagePart::Ptr SemanticProcessor::process(MimeTreeParser::Interface::BodyPart &part) const
auto nodeHelper = part.nodeHelper();
......@@ -71,7 +84,7 @@ MimeTreeParser::MessagePart::Ptr SemanticProcessor::process(MimeTreeParser::Inte
// try the unstructured data extractor as a fallback
if (memento->isEmpty()) {
const auto extractors = m_repository.extractorsForMessage(part.content());
const auto extractors = m_repository->extractorsForMessage(part.content());
if (extractors.empty()) {
return {};
......@@ -26,14 +26,20 @@
#include <MimeTreeParser/BodyPartFormatter>
#include <MimeTreeParser/MessagePart>
#include <memory>
/** Processor plugin for MimeTreeParser. */
class SemanticProcessor : public MimeTreeParser::Interface::BodyPartFormatter
MimeTreeParser::MessagePart::Ptr process(MimeTreeParser::Interface::BodyPart &part) const override;
ExtractorRepository m_repository;
std::shared_ptr<ExtractorRepository> m_repository;
static std::weak_ptr<ExtractorRepository> s_repository;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment