mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-01-03 16:47:53 -08:00
Optimize cipt parsing by early returning (#5727)
This commit is contained in:
@@ -24,6 +24,12 @@
|
||||
*/
|
||||
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 _)
|
||||
auto isShortnameDivider = [](const QChar &c) {
|
||||
return c == '_' || (!c.isLetterOrNumber() && c != '\'' && c != '\"');
|
||||
|
||||
Reference in New Issue
Block a user