Minor cleanup tweaks in Regex (dotnet/corefx#40338)
authorStephen Toub <stoub@microsoft.com>
Fri, 16 Aug 2019 00:35:39 +0000 (20:35 -0400)
committerGitHub <noreply@github.com>
Fri, 16 Aug 2019 00:35:39 +0000 (20:35 -0400)
* Remove unused local in RegexRunner.TextposDescription

* Remove redundant checks in RegexCharClass.AddRange

Commit migrated from https://github.com/dotnet/corefx/commit/04bd3fa5c2c7d379c22b805ad840bc28423d5242

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCharClass.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexRunner.cs

index 2abe927..ceb7580 100644 (file)
@@ -517,8 +517,7 @@ namespace System.Text.RegularExpressions
         public void AddRange(char first, char last)
         {
             _rangelist.Add(new SingleRange(first, last));
-            if (_canonical && _rangelist.Count > 0 &&
-                first <= _rangelist[_rangelist.Count - 1].Last)
+            if (_canonical && first <= last)
             {
                 _canonical = false;
             }
index 92d0c72..7fd53e5 100644 (file)
@@ -595,7 +595,6 @@ namespace System.Text.RegularExpressions
         internal virtual string TextposDescription()
         {
             var sb = new StringBuilder();
-            int remaining;
 
             sb.Append(runtextpos);
 
@@ -609,8 +608,6 @@ namespace System.Text.RegularExpressions
 
             sb.Append('>');
 
-            remaining = runtextend - runtextpos;
-
             for (int i = runtextpos; i < runtextend; i++)
             {
                 sb.Append(RegexCharClass.CharDescription(runtext[i]));