From 87e4971a68114987d81a21ba6df9035e30255c51 Mon Sep 17 00:00:00 2001 From: Adam Sitnik Date: Tue, 1 Oct 2019 03:25:29 +0200 Subject: [PATCH] allow ASCII equality ordinal fast path for en-* cultures (#26905) * allow ASCII equality ordinal fast path for en-* cultures * dont use StartsWith in the initialization execution path * Update src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs Co-Authored-By: Jan Kotas --- .../shared/System/Globalization/CompareInfo.Unix.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs index 3388c09e1c23..4e42a543ba28 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs @@ -32,7 +32,12 @@ private void InitSort(CultureInfo culture) } else { - _isAsciiEqualityOrdinal = (_sortName == "en-US" || _sortName == ""); + // Inline the following condition to avoid potential implementation cycles within globalization + // + // _isAsciiEqualityOrdinal = _sortName == "" || _sortName == "en" || _sortName.StartsWith("en-", StringComparison.Ordinal); + // + _isAsciiEqualityOrdinal = _sortName.Length == 0 || + (_sortName.Length >= 2 && _sortName[0] == 'e' && _sortName[1] == 'n' && (_sortName.Length == 2 || _sortName[2] == '-')); _sortHandle = SortHandleCache.GetCachedSortHandle(_sortName); }