Imported Upstream version 6.4.0.137

Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-07-26 19:53:28 +00:00
parent e9207cf623
commit ef583813eb
2712 changed files with 74169 additions and 40587 deletions

View File

@ -26,6 +26,10 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Disable unreachable code warnings in this entire file.
#pragma warning disable 162
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Mono.Globalization.Unicode;
@ -33,16 +37,44 @@ using System.Threading;
namespace System.Globalization
{
interface ISimpleCollator
{
SortKey GetSortKey (string source, CompareOptions options);
int Compare (string s1, string s2);
int Compare (string s1, int idx1, int len1, string s2, int idx2, int len2, CompareOptions options);
bool IsPrefix (string src, string target, CompareOptions opt);
bool IsSuffix (string src, string target, CompareOptions opt);
int IndexOf (string s, string target, int start, int length, CompareOptions opt);
int IndexOf (string s, char target, int start, int length, CompareOptions opt);
int LastIndexOf (string s, string target, CompareOptions opt);
int LastIndexOf (string s, string target, int start, int length, CompareOptions opt);
int LastIndexOf (string s, char target, CompareOptions opt);
int LastIndexOf (string s, char target, int start, int length, CompareOptions opt);
}
partial class CompareInfo
{
[NonSerialized]
SimpleCollator collator;
ISimpleCollator collator;
// Maps culture IDs to SimpleCollator objects
static Dictionary<string, SimpleCollator> collators;
static Dictionary<string, ISimpleCollator> collators;
static bool managedCollation;
static bool managedCollationChecked;
#if WASM
const bool UseManagedCollation = false;
#else
static bool UseManagedCollation {
get {
if (!managedCollationChecked) {
@ -53,14 +85,18 @@ namespace System.Globalization
return managedCollation;
}
}
#endif
SimpleCollator GetCollator ()
ISimpleCollator GetCollator ()
{
#if WASM
return null;
#else
if (collator != null)
return collator;
if (collators == null) {
Interlocked.CompareExchange (ref collators, new Dictionary<string, SimpleCollator> (StringComparer.Ordinal), null);
Interlocked.CompareExchange (ref collators, new Dictionary<string, ISimpleCollator> (StringComparer.Ordinal), null);
}
lock (collators) {
@ -71,6 +107,7 @@ namespace System.Globalization
}
return collator;
#endif
}
SortKey CreateSortKeyCore (string source, CompareOptions options)