Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
allow ASCII equality ordinal fast path for en-* cultures (#26905)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
adamsitnik and jkotas authored Oct 1, 2019
1 parent 7fd7985 commit 87e4971
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 87e4971

Please sign in to comment.