1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 17:27:24 +08:00

Use ordinal comparison when searching at song select

Bypasses various overheads. In theory should be fine? (until it's not on some language)
This commit is contained in:
Dean Herbert 2023-12-05 14:12:25 +09:00
parent 1292c322c0
commit 7fda38d0b0
No known key found for this signature in database

View File

@ -176,13 +176,15 @@ namespace osu.Game.Screens.Select
{
default:
case MatchMode.Substring:
return value.Contains(SearchTerm, StringComparison.InvariantCultureIgnoreCase);
// Note that we are using ordinal here to avoid performance issues caused by globalisation concerns.
// See https://github.com/ppy/osu/issues/11571 / https://github.com/dotnet/docs/issues/18423.
return value.Contains(SearchTerm, StringComparison.OrdinalIgnoreCase);
case MatchMode.IsolatedPhrase:
return Regex.IsMatch(value, $@"(^|\s){Regex.Escape(searchTerm)}($|\s)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
case MatchMode.FullPhrase:
return CultureInfo.InvariantCulture.CompareInfo.Compare(value, searchTerm, CompareOptions.IgnoreCase) == 0;
return CultureInfo.InvariantCulture.CompareInfo.Compare(value, searchTerm, CompareOptions.OrdinalIgnoreCase) == 0;
}
}