mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-28 17:43:54 -07:00
Optimize cipt parsing by early returning (#5727)
This commit is contained in:
parent
b58b85dc0f
commit
c99afe7956
1 changed files with 6 additions and 0 deletions
|
|
@ -24,6 +24,12 @@
|
||||||
*/
|
*/
|
||||||
bool parseCipt(const QString &name, const QString &text)
|
bool parseCipt(const QString &name, const QString &text)
|
||||||
{
|
{
|
||||||
|
// Use precompiled regex to check if text is a possible candidate, and early return if not
|
||||||
|
static auto prelimCheck = QRegularExpression(" enters( the battlefield)? tapped(?! unless)");
|
||||||
|
if (!prelimCheck.match(text).hasMatch()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Try to split shortname on most non-alphanumeric characters (including _)
|
// Try to split shortname on most non-alphanumeric characters (including _)
|
||||||
auto isShortnameDivider = [](const QChar &c) {
|
auto isShortnameDivider = [](const QChar &c) {
|
||||||
return c == '_' || (!c.isLetterOrNumber() && c != '\'' && c != '\"');
|
return c == '_' || (!c.isLetterOrNumber() && c != '\'' && c != '\"');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue