From a6c5320e08b49eb5f9772af8f2f00d30c8a21820 Mon Sep 17 00:00:00 2001 From: Justin Van Patten Date: Tue, 23 Aug 2016 20:16:22 -0700 Subject: [PATCH] DateTimeFormat: Avoid intermediate char[] allocation (dotnet/coreclr#6863) An unnecessary intermediate char[] allocation can be avoided by calling `new string(c, 1)` instead of `new string(new char[] { c })`. Commit migrated from https://github.com/dotnet/coreclr/commit/d014a8fab82d2ff70185ae6c29d2ae5a4074cc00 --- src/coreclr/src/mscorlib/src/System/Globalization/DateTimeFormat.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/src/mscorlib/src/System/Globalization/DateTimeFormat.cs b/src/coreclr/src/mscorlib/src/System/Globalization/DateTimeFormat.cs index cbb4039..228e5f5 100644 --- a/src/coreclr/src/mscorlib/src/System/Globalization/DateTimeFormat.cs +++ b/src/coreclr/src/mscorlib/src/System/Globalization/DateTimeFormat.cs @@ -1009,7 +1009,7 @@ namespace System { case 'O': case 's': case 'u': - results = new String[] {Format(dateTime, new String(new char[] {format}), dtfi)}; + results = new String[] {Format(dateTime, new String(format, 1), dtfi)}; break; default: throw new FormatException(Environment.GetResourceString("Format_InvalidString")); -- 2.7.4