From 1429a78a502aee66a1ec5a6580d7ea87c7e37d10 Mon Sep 17 00:00:00 2001 From: Justin Van Patten Date: Wed, 6 Jul 2016 22:39:34 -0700 Subject: [PATCH] Avoid box allocation in DateTimeFormat.FormatCustomized (dotnet/coreclr#6147) The current implementation calls `string.Concat(object, object)`, which results in an `int` box allocation. Avoid the box allocation by calling `int.ToString()`, allowing `string.Concat(string, string)` to be used. Commit migrated from https://github.com/dotnet/coreclr/commit/62482f58b025eebd05101e33f2d2253fee070ab5 --- 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 cdb7032..cbb4039 100644 --- a/src/coreclr/src/mscorlib/src/System/Globalization/DateTimeFormat.cs +++ b/src/coreclr/src/mscorlib/src/System/Globalization/DateTimeFormat.cs @@ -606,7 +606,7 @@ namespace System { FormatDigits(result, year % 100, tokenLen); } else { - String fmtPattern = "D" + tokenLen; + String fmtPattern = "D" + tokenLen.ToString(); result.Append(year.ToString(fmtPattern, CultureInfo.InvariantCulture)); } } -- 2.7.4