From c99afe7956945f6fcee7a5d782a6ce2dc3457578 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Sat, 15 Mar 2025 14:23:41 -0700 Subject: [PATCH] Optimize cipt parsing by early returning (#5727) --- oracle/src/parsehelpers.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oracle/src/parsehelpers.cpp b/oracle/src/parsehelpers.cpp index c7f340139..a97bf67c9 100644 --- a/oracle/src/parsehelpers.cpp +++ b/oracle/src/parsehelpers.cpp @@ -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 != '\"');