Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@ -1452,9 +1452,9 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
public unsafe int IndexOf (string s, string target, int start, int length, CompareOptions opt)
{
if (opt == CompareOptions.Ordinal)
return IndexOfOrdinal (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
if (opt == CompareOptions.OrdinalIgnoreCase)
return IndexOfOrdinalIgnoreCase (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
if (opt == CompareOptions.None) {
bool testWasUnable;
int ret = QuickIndexOf (s, target, start, length, out testWasUnable);
@ -1503,30 +1503,6 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
return -1;
}
int IndexOfOrdinalIgnoreCase (string s, string target, int start, int length)
{
if (target.Length == 0)
return 0;
else if (target.Length > length)
return -1;
int end = start + length - target.Length + 1;
for (int i = start; i < end; i++) {
bool no = false;
for (int j = 0; j < target.Length; j++) {
// I think almost all text has more lower letters than upper ones. Thus with this invariant comparison ToLower() should be faster since it costs less operations.
if (textInfo.ToLower (s [i + j]) != textInfo.ToLower (target [j])) {
no = true;
break;
}
}
if (no)
continue;
return i;
}
return -1;
}
// char
public int IndexOf (string s, char target, CompareOptions opt)
@ -1537,9 +1513,9 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
public unsafe int IndexOf (string s, char target, int start, int length, CompareOptions opt)
{
if (opt == CompareOptions.Ordinal)
return IndexOfOrdinal (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
if (opt == CompareOptions.OrdinalIgnoreCase)
return IndexOfOrdinalIgnoreCase (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
byte* alwaysMatchFlags = stackalloc byte [16];
byte* neverMatchFlags = stackalloc byte [16];
byte* targetSortKey = stackalloc byte [4];
@ -1588,16 +1564,6 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
return -1;
}
int IndexOfOrdinalIgnoreCase (string s, char target, int start, int length)
{
int end = start + length;
target = textInfo.ToLower (target);
for (int i = start; i < end; i++)
if (textInfo.ToLower (s [i]) == target)
return i;
return -1;
}
// Searches target byte[] keydata
unsafe int IndexOfSortKey (string s, int start, int length, byte* sortkey, char target, int ti, bool noLv4, ref Context ctx)
{
@ -1695,7 +1661,7 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
if (opt == CompareOptions.Ordinal)
return LastIndexOfOrdinal (s, target, start, length);
if (opt == CompareOptions.OrdinalIgnoreCase)
return LastIndexOfOrdinalIgnoreCase (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
byte* alwaysMatchFlags = stackalloc byte [16];
byte* neverMatchFlags = stackalloc byte [16];
byte* targetSortKey = stackalloc byte [4];
@ -1740,34 +1706,6 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
return -1;
}
int LastIndexOfOrdinalIgnoreCase (string s, string target, int start, int length)
{
if (target.Length == 0)
return start;
if (s.Length < length || target.Length > length)
return -1;
int end = start - length + target.Length - 1;
char tail = textInfo.ToLower (target [target.Length - 1]);
for (int i = start; i > end;) {
if (textInfo.ToLower (s [i]) != tail) {
i--;
continue;
}
int x = i - target.Length + 1;
i--;
bool mismatch = false;
for (int j = target.Length - 2; j >= 0; j--)
if (textInfo.ToLower (s [x + j]) != textInfo.ToLower (target [j])) {
mismatch = true;
break;
}
if (mismatch)
continue;
return x;
}
return -1;
}
// char
public int LastIndexOf (string s, char target, CompareOptions opt)
@ -1778,9 +1716,9 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
public unsafe int LastIndexOf (string s, char target, int start, int length, CompareOptions opt)
{
if (opt == CompareOptions.Ordinal)
return LastIndexOfOrdinal (s, target, start, length);
throw new NotSupportedException ();
if (opt == CompareOptions.OrdinalIgnoreCase)
return LastIndexOfOrdinalIgnoreCase (s, target, start, length);
throw new NotSupportedException ();
byte* alwaysMatchFlags = stackalloc byte [16];
byte* neverMatchFlags = stackalloc byte [16];
byte* targetSortKey = stackalloc byte [4];
@ -1823,29 +1761,6 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
}
}
int LastIndexOfOrdinal (string s, char target, int start, int length)
{
if (s.Length == 0)
return -1;
int end = start - length;
for (int i = start; i > end; i--)
if (s [i] == target)
return i;
return -1;
}
int LastIndexOfOrdinalIgnoreCase (string s, char target, int start, int length)
{
if (s.Length == 0)
return -1;
int end = start - length;
char c = textInfo.ToUpper (target);
for (int i = start; i > end; i--)
if (textInfo.ToUpper (s [i]) == c)
return i;
return -1;
}
// Searches target byte[] keydata
unsafe int LastIndexOfSortKey (string s, int start, int orgStart, int length, byte* sortkey, int ti, bool noLv4, ref Context ctx)
{