Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Dan Moseley <danmose@microsoft.com>
  • Loading branch information
stephentoub and danmoseley committed Feb 11, 2020
1 parent 7be23b7 commit 207bf94
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2831,6 +2831,7 @@ void EmitSingleCharAtomicLoop(RegexNode node)
}
else if (node.Type == RegexNode.Setloopatomic &&
maxIterations == int.MaxValue &&
!IsCaseInsensitive(node) &&
(numSetChars = RegexCharClass.GetSetChars(node.Str!, setChars)) > 1 &&
RegexCharClass.IsNegated(node.Str!))
{
Expand All @@ -2857,6 +2858,7 @@ void EmitSingleCharAtomicLoop(RegexNode node)
}
else
{
Debug.Assert(numSetChars == 3);
Ldc(setChars[2]);
Call(s_spanIndexOfAnyCharCharChar);
}
Expand Down Expand Up @@ -4547,6 +4549,7 @@ private void GenerateOneCode()
}
else
{
Debug.Assert(numSetChars == 3);
Ldc(setChars[2]);
Call(s_spanIndexOfAnyCharCharChar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ public static IEnumerable<object[]> Groups_Basic_TestData()
yield return new object[] { null, @"[ace]?b[ace]?b[ace]?b[ace]?b", "cBbAbEb", RegexOptions.IgnoreCase, new string[] { "cBbAbEb" } };
yield return new object[] { null, @"a[^wz]*w", "abcdcdcdwz", RegexOptions.None, new string[] { "abcdcdcdw" } };
yield return new object[] { null, @"a[^wyz]*w", "abcdcdcdwz", RegexOptions.None, new string[] { "abcdcdcdw" } };
yield return new object[] { null, @"a[^wyz]*W", "abcdcdcdWz", RegexOptions.IgnoreCase, new string[] { "abcdcdcdW" } };
// Implicitly upgrading (or not) concat loops to be atomic
yield return new object[] { null, @"(?:[ab]c[de]f)*", "", RegexOptions.None, new string[] { "" } };
yield return new object[] { null, @"(?:[ab]c[de]f)*", "acdf", RegexOptions.None, new string[] { "acdf" } };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public static IEnumerable<object[]> Match_Basic_TestData()
yield return new object[] { Case("(?>hi|hello|hey)hi"), "hellohi", options, 0, 0, false, string.Empty };
yield return new object[] { Case("(?:hi|hello|hey)hi"), "hellohi", options, 0, 7, true, "hellohi" }; // allow backtracking and it succeeds
yield return new object[] { Case("(?>hi|hello|hey)hi"), "hihi", options, 0, 4, true, "hihi" };
yield return new object[] { Case(@"a[^wyz]*w"), "abczw", RegexOptions.IgnoreCase, 0, 0, false, string.Empty };
}

// Using beginning/end of string chars \A, \Z: Actual - "\\Aaaa\\w+zzz\\Z"
Expand Down

0 comments on commit 207bf94

Please sign in to comment.