mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-19 21:40:45 +00:00
Create the QRegularExpression in the TextNode constructor instead of for
each row in the filtered table. On a table of more than 1M entries it speeds up filtering almost tenfold (from 35s to 4s).
This commit is contained in:
parent
bd003f109e
commit
8717e8e487
@ -13,6 +13,8 @@
|
|||||||
CSMFilter::TextNode::TextNode(int columnId, const std::string& text)
|
CSMFilter::TextNode::TextNode(int columnId, const std::string& text)
|
||||||
: mColumnId(columnId)
|
: mColumnId(columnId)
|
||||||
, mText(text)
|
, mText(text)
|
||||||
|
, mRegExp(QRegularExpression::anchoredPattern(QString::fromUtf8(mText.c_str())),
|
||||||
|
QRegularExpression::CaseInsensitiveOption)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,9 +59,7 @@ bool CSMFilter::TextNode::test(const CSMWorld::IdTableBase& table, int row, cons
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/// \todo make pattern syntax configurable
|
/// \todo make pattern syntax configurable
|
||||||
QRegularExpression regExp(QRegularExpression::anchoredPattern(QString::fromUtf8(mText.c_str())),
|
QRegularExpressionMatch match = mRegExp.match(string);
|
||||||
QRegularExpression::CaseInsensitiveOption);
|
|
||||||
QRegularExpressionMatch match = regExp.match(string);
|
|
||||||
|
|
||||||
return match.hasMatch();
|
return match.hasMatch();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include <apps/opencs/model/world/idtablebase.hpp>
|
#include <apps/opencs/model/world/idtablebase.hpp>
|
||||||
|
|
||||||
#include "leafnode.hpp"
|
#include "leafnode.hpp"
|
||||||
@ -15,6 +17,7 @@ namespace CSMFilter
|
|||||||
{
|
{
|
||||||
int mColumnId;
|
int mColumnId;
|
||||||
std::string mText;
|
std::string mText;
|
||||||
|
QRegularExpression mRegExp;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextNode(int columnId, const std::string& text);
|
TextNode(int columnId, const std::string& text);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user