From bcb479d4f70d7f268dc54b4f6265ad2b40496507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 3 Jul 2024 16:13:30 +0200 Subject: [PATCH] Use one less regex --- osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs index b6339851ef..00482a72fc 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckTitleMarkers.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Collections.Generic; using System.Text.RegularExpressions; using osu.Game.Rulesets.Edit.Checks.Components; @@ -37,10 +38,10 @@ namespace osu.Game.Rulesets.Edit.Checks { bool hasRomanisedTitle = unicodeTitle != romanisedTitle; - if (check.AnyRegex.IsMatch(unicodeTitle) && !check.ExactRegex.IsMatch(unicodeTitle)) + if (check.AnyRegex.IsMatch(unicodeTitle) && !unicodeTitle.Contains(check.CorrectMarkerFormat, StringComparison.Ordinal)) yield return new IssueTemplateIncorrectMarker(this).Create("Title", check.CorrectMarkerFormat); - if (hasRomanisedTitle && check.AnyRegex.IsMatch(romanisedTitle) && !check.ExactRegex.IsMatch(romanisedTitle)) + if (hasRomanisedTitle && check.AnyRegex.IsMatch(romanisedTitle) && !romanisedTitle.Contains(check.CorrectMarkerFormat, StringComparison.Ordinal)) yield return new IssueTemplateIncorrectMarker(this).Create("Romanised title", check.CorrectMarkerFormat); } } @@ -48,13 +49,11 @@ namespace osu.Game.Rulesets.Edit.Checks private class MarkerCheck { public readonly string CorrectMarkerFormat; - public readonly Regex ExactRegex; public readonly Regex AnyRegex; public MarkerCheck(string exact, string anyRegex) { CorrectMarkerFormat = exact; - ExactRegex = new Regex(Regex.Escape(exact), RegexOptions.Compiled); AnyRegex = new Regex(anyRegex, RegexOptions.Compiled); } }