Module.Name: Avoid unnecessary char[] allocation (#6865)
authorJustin Van Patten <jvp@justinvp.com>
Wed, 24 Aug 2016 03:21:45 +0000 (20:21 -0700)
committerJan Kotas <jkotas@microsoft.com>
Wed, 24 Aug 2016 03:21:45 +0000 (20:21 -0700)
Instead of `new string(s.ToCharArray(), i + 1, s.Length - i - 1)`, use
the simpler `string.Substring(i + 1)` to avoid the unnecessary
intermediate char[] allocation.

src/mscorlib/src/System/Reflection/Module.cs

index 6bf0ace..34705a4 100644 (file)
@@ -1187,7 +1187,7 @@ namespace System.Reflection
                 if (i == -1)
                     return s;
 
-                return new String(s.ToCharArray(), i + 1, s.Length - i - 1);
+                return s.Substring(i + 1);
             }
         }