From bf80a9007264a576a131715816d8ba1594f39742 Mon Sep 17 00:00:00 2001 From: Justin Van Patten Date: Tue, 23 Aug 2016 20:21:45 -0700 Subject: [PATCH] Module.Name: Avoid unnecessary char[] allocation (dotnet/coreclr#6865) 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. Commit migrated from https://github.com/dotnet/coreclr/commit/cacf46feb64583d1e774a2a3c9c12da1120effa7 --- src/coreclr/src/mscorlib/src/System/Reflection/Module.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Module.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Module.cs index 6bf0ace..34705a4 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Module.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Module.cs @@ -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); } } -- 2.7.4