public class CompareInfo : IDeserializationCallback
{
static readonly bool useManagedCollation =
- Environment.internalGetEnvironmentVariable ("MONO_USE_MANAGED_COLLATION")
- == "yes";
+ Environment.internalGetEnvironmentVariable ("MONO_DISABLE_MANAGED_COLLATION")
+ != "yes" && MSCompatUnicodeTable.IsReady;
internal static bool UseManagedCollation {
- get { return useManagedCollation && MSCompatUnicodeTable.IsReady; }
+ get { return useManagedCollation; }
}
// Keep in synch with MonoCompareInfo in the runtime.
[NonSerialized]
private IntPtr ICU_collator;
private int win32LCID; // Unused, but MS.NET serializes this
+#if NET_2_0
+ private string m_name; // Unused, but MS.NET serializes this
+#endif
[NonSerialized]
SimpleCollator collator;
public virtual SortKey GetSortKey(string source,
CompareOptions options)
{
+#if NET_2_0
+ switch (options) {
+ case CompareOptions.Ordinal:
+ case CompareOptions.OrdinalIgnoreCase:
+ throw new ArgumentException ("Now allowed CompareOptions.", "options");
+ }
+#endif
if (UseManagedCollation)
return collator.GetSortKey (source, options);
SortKey key=new SortKey (culture, source, options);
int count, char c, CompareOptions opt,
bool first)
{
- return UseManagedCollation &&
- (CompareOptions.Ordinal & opt) == 0 ?
+ // - forward IndexOf() icall is much faster than
+ // manged version, so always use icall. However,
+ // it does not work for OrdinalIgnoreCase, so
+ // do not avoid managed collator for that option.
+ return UseManagedCollation && ! (first && opt == CompareOptions.Ordinal) ?
internal_index_managed (s, sindex, count, c, opt, first) :
internal_index (s, sindex, count, c, opt, first);
}
int count, string s2, CompareOptions opt,
bool first)
{
- return UseManagedCollation &&
- (CompareOptions.Ordinal & opt) == 0 ?
+ // - forward IndexOf() icall is much faster than
+ // manged version, so always use icall. However,
+ // it does not work for OrdinalIgnoreCase, so
+ // do not avoid managed collator for that option.
+ return UseManagedCollation && ! (first && opt == CompareOptions.Ordinal) ?
internal_index_managed (s1, sindex, count, s2, opt, first) :
internal_index (s1, sindex, count, s2, opt, first);
}
}
#if NET_2_0
- public bool IsSortable (char c)
+ public static bool IsSortable (char c)
{
return MSCompatUnicodeTable.IsSortable (c);
}
- public bool IsSortable (string s)
+ public static bool IsSortable (string s)
{
return MSCompatUnicodeTable.IsSortable (s);
}