Skip to content

Commit

Permalink
XForm: Make Contains consistent block/non-block (just IndexOf)
Browse files Browse the repository at this point in the history
  - Disable generate String8Comparer (custom code right now).
  • Loading branch information
Scott Louvau committed Jan 28, 2018
1 parent 314b9e5 commit bcb336b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions XForm/XForm.Generator/ComparerGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public static void GenerateAll(string outputPath)

foreach (string type in SupportedTypes.AdditionalTypes)
{
// Don't generate String8Comparer for now - ContainsBlock logic.
if (type.Equals("String8")) continue;

Generate(type, outputPath);
}

Expand Down
8 changes: 4 additions & 4 deletions XForm/XForm/Types/Comparers/String8Comparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace XForm.Types.Comparers
{
/// <summary>
/// IXArrayComparer for String8[].
/// GENERATED by XForm.Generator\ComparerGenerator.cs
/// NOT GENERATED; CompareBlock is customized.
/// </summary>
internal class String8Comparer : IXArrayComparer, IXArrayTextComparer, IXArrayComparer<String8>
{
Expand Down Expand Up @@ -472,7 +472,7 @@ public void WhereContains(XArray left, XArray right, BitVector vector)
// Slow Path: Look up indices on both sides. ~55ms for 16M
for (int i = 0; i < left.Count; ++i)
{
if (leftArray[left.Index(i)].Contains(rightArray[right.Index(i)]) != -1) vector.Set(i);
if (leftArray[left.Index(i)].IndexOf(rightArray[right.Index(i)]) != -1) vector.Set(i);
}
}
else if (!right.Selector.IsSingleValue)
Expand All @@ -488,7 +488,7 @@ public void WhereContains(XArray left, XArray right, BitVector vector)
int leftIndexToRightIndex = right.Selector.StartIndexInclusive - left.Selector.StartIndexInclusive;
for (int i = left.Selector.StartIndexInclusive; i < left.Selector.EndIndexExclusive; ++i)
{
if (leftArray[i].Contains(rightArray[i + leftIndexToRightIndex]) != -1) vector.Set(i - zeroOffset);
if (leftArray[i].IndexOf(rightArray[i + leftIndexToRightIndex]) != -1) vector.Set(i - zeroOffset);
}
}
}
Expand Down Expand Up @@ -535,7 +535,7 @@ public void WhereContains(XArray left, XArray right, BitVector vector)

public bool WhereContains(String8 left, String8 right)
{
return left.Contains(right) != -1;
return left.IndexOf(right) != -1;
}

public void WhereContainsExact(XArray left, XArray right, BitVector vector)
Expand Down

0 comments on commit bcb336b

Please sign in to comment.