Optimize cipt parsing by early returning (#5727)

This commit is contained in:
RickyRister
2025-03-15 14:23:41 -07:00
committed by GitHub
parent b58b85dc0f
commit c99afe7956

View File

@@ -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 != '\"');