Avoid repeated char[] allocations in CheckForColonInFirstPathSegment
authorJames Ko <jamesqko@gmail.com>
Fri, 8 Jul 2016 00:57:05 +0000 (20:57 -0400)
committerJames Ko <jamesqko@gmail.com>
Fri, 8 Jul 2016 00:57:05 +0000 (20:57 -0400)
Commit migrated from https://github.com/dotnet/corefx/commit/1962d3f68e4d547cd1904f435e939c63b137cf1d

src/libraries/System.Private.Uri/src/System/Uri.cs

index c1a6b66..80524b3 100644 (file)
@@ -1704,12 +1704,14 @@ namespace System
         // 
         // Returns true if a colon is found in the first path segment, false otherwise
         // 
+
+        // Check for anything that may terminate the first regular path segment
+        // or an illegal colon
+        private static readonly char[] s_pathDelims = { ':', '\\', '/', '?', '#' };
+
         private static bool CheckForColonInFirstPathSegment(string uriString)
         {
-            // Check for anything that may terminate the first regular path segment
-            // or an illegal colon
-            char[] pathDelims = new char[] { ':', '\\', '/', '?', '#' };
-            int index = uriString.IndexOfAny(pathDelims);
+            int index = uriString.IndexOfAny(s_pathDelims);
 
             return (index >= 0 && uriString[index] == ':');
         }