unsafe internal struct Context
{
- public Context (CompareOptions opt, byte* alwaysMatchFlags, byte* neverMatchFlags, byte* buffer1, byte* buffer2, byte* prev1, bool quickCheckPossible)
+ public Context (CompareOptions opt, byte* alwaysMatchFlags, byte* neverMatchFlags, byte* buffer1, byte* buffer2, byte* prev1/*, bool quickCheckPossible*/)
{
Option = opt;
AlwaysMatchFlags = alwaysMatchFlags;
Buffer2 = buffer2;
PrevSortKey = prev1;
PrevCode = -1;
- QuickCheckPossible = quickCheckPossible;
+// QuickCheckPossible = quickCheckPossible;
}
public readonly CompareOptions Option;
public byte* Buffer2;
public int PrevCode;
public byte* PrevSortKey;
- public readonly bool QuickCheckPossible;
+// public readonly bool QuickCheckPossible;
public void ClearPrevInfo ()
{
{
byte* prevbuf = stackalloc byte [4];
ClearBuffer (prevbuf, 4);
- Context ctx = new Context (opt, null, null, null, null, prevbuf, false);
+ Context ctx = new Context (opt, null, null, null, null, prevbuf);
for (int n = start; n < end; n++) {
int i = s [n];
public int Compare (string s1, string s2)
{
- return Compare (s1, s2, CompareOptions.None);
+ return Compare (s1, 0, s1.Length, s2, 0, s2.Length, CompareOptions.None);
}
-
- public int Compare (string s1, string s2, CompareOptions options)
- {
- return Compare (s1, 0, s1.Length, s2, 0, s2.Length, options);
- }
-
+/*
private int CompareOrdinal (string s1, int idx1, int len1,
string s2, int idx2, int len2)
{
return len1 == len2 ? 0 :
len1 == min ? - 1 : 1;
}
-
- public unsafe int Compare (string s1, int idx1, int len1,
+*/
+ internal unsafe int Compare (string s1, int idx1, int len1,
string s2, int idx2, int len2, CompareOptions options)
{
- // quick equality check
- if (idx1 == idx2 && len1 == len2 &&
- Object.ReferenceEquals (s1, s2))
- return 0;
- if (options == CompareOptions.Ordinal)
- return CompareOrdinal (s1, idx1, len1, s2, idx2, len2);
- if (options == CompareOptions.OrdinalIgnoreCase)
- return CompareOrdinalIgnoreCase (s1, idx1, len1, s2, idx2, len2);
-
#if false // stable easy version, depends on GetSortKey().
SortKey sk1 = GetSortKey (s1, idx1, len1, options);
SortKey sk2 = GetSortKey (s2, idx2, len2, options);
byte* sk2 = stackalloc byte [4];
ClearBuffer (sk1, 4);
ClearBuffer (sk2, 4);
- Context ctx = new Context (options, null, null, sk1, sk2, null,
- QuickCheckPossible (s1, idx1, idx1 + len1, s2, idx2, idx2 + len2));
+ Context ctx = new Context (options, null, null, sk1, sk2, null);
+ // QuickCheckPossible (s1, idx1, idx1 + len1, s2, idx2, idx2 + len2));
bool dummy, dummy2;
int ret = CompareInternal (s1, idx1, len1, s2, idx2, len2, out dummy, out dummy2, true, false, ref ctx);
buffer [i] = 0;
}
+/*
bool QuickCheckPossible (string s1, int idx1, int end1,
string s2, int idx2, int end2)
{
return true;
#endif
}
+*/
unsafe int CompareInternal (string s1, int idx1, int len1, string s2,
int idx2, int len2,
sourceConsumed = false;
PreviousInfo prev2 = new PreviousInfo (false);
- if (opt == CompareOptions.None && ctx.QuickCheckPossible)
- return CompareQuick (s1, idx1, len1, s2, idx2, len2, out sourceConsumed, out targetConsumed, immediateBreakup);
+// if (opt == CompareOptions.None && ctx.QuickCheckPossible)
+// return CompareQuick (s1, idx1, len1, s2, idx2, len2, out sourceConsumed, out targetConsumed, immediateBreakup);
// It holds final result that comes from the comparison
// at level 2 or lower. Even if Compare() found the
byte* sk2 = stackalloc byte [4];
ClearBuffer (sk1, 4);
ClearBuffer (sk2, 4);
- Context ctx = new Context (opt, null, null, sk1, sk2, null,
- QuickCheckPossible (s, start, start + length, target, 0, target.Length));
+ Context ctx = new Context (opt, null, null, sk1, sk2, null);
+ //QuickCheckPossible (s, start, start + length, target, 0, target.Length));
return IsPrefix (s, target, start, length, true, ref ctx);
}
ClearBuffer (targetSortKey, 4);
ClearBuffer (sk1, 4);
ClearBuffer (sk2, 4);
- Context ctx = new Context (opt, alwaysMatchFlags, neverMatchFlags, sk1, sk2, null, false);
+ Context ctx = new Context (opt, alwaysMatchFlags, neverMatchFlags, sk1, sk2, null);
return IndexOf (s, target, start, length,
targetSortKey, ref ctx);
ClearBuffer (targetSortKey, 4);
ClearBuffer (sk1, 4);
ClearBuffer (sk2, 4);
- Context ctx = new Context (opt, alwaysMatchFlags, neverMatchFlags, sk1, sk2, null, false);
+ Context ctx = new Context (opt, alwaysMatchFlags, neverMatchFlags, sk1, sk2, null);
// If target is contraction, then use string search.
Contraction ct = GetContraction (target);
ClearBuffer (sk1, 4);
ClearBuffer (sk2, 4);
// For some unknown reason CompareQuick() does not work fine w/ LastIndexOf().
- Context ctx = new Context (opt, alwaysMatchFlags, neverMatchFlags, sk1, sk2, null, false);
+ Context ctx = new Context (opt, alwaysMatchFlags, neverMatchFlags, sk1, sk2, null);
return LastIndexOf (s, target, start, length,
targetSortKey, ref ctx);
}
ClearBuffer (targetSortKey, 4);
ClearBuffer (sk1, 4);
ClearBuffer (sk2, 4);
- Context ctx = new Context (opt, alwaysMatchFlags, neverMatchFlags, sk1, sk2, null, false);
+ Context ctx = new Context (opt, alwaysMatchFlags, neverMatchFlags, sk1, sk2, null);
// If target is a replacement contraction, then use
// string search.