Cache rule regular expressions for performance

--HG--
branch : magao-dev
This commit is contained in:
Tim Delaney
2017-02-11 18:43:50 +11:00
parent f9abd254f4
commit a844ccb06a
2 changed files with 38 additions and 7 deletions

View File

@@ -36,6 +36,7 @@
#include <QSharedPointer>
#include <QStringList>
template <class T, class U> class QHash;
class QRegularExpression;
namespace Rss
@@ -57,6 +58,7 @@ namespace Rss
};
DownloadRule();
~DownloadRule();
static DownloadRulePtr fromVariantHash(const QVariantHash &ruleHash);
QVariantHash toVariantHash() const;
@@ -91,6 +93,7 @@ namespace Rss
private:
bool matches(const QString &articleTitle, const QString &expression) const;
QRegularExpression getRegex(const QString &expression, bool isRegex = true) const;
QString m_name;
QStringList m_mustContain;
@@ -104,6 +107,7 @@ namespace Rss
AddPausedState m_apstate;
QDateTime m_lastMatch;
int m_ignoreDays;
mutable QHash<QString, QRegularExpression> *m_cachedRegexes;
};
}