Avoid box allocation in TypeBuilder.DefineDataHelper (dotnet/coreclr#6148)
authorJustin Van Patten <jvp@justinvp.com>
Thu, 7 Jul 2016 05:37:53 +0000 (22:37 -0700)
committerJan Kotas <jkotas@microsoft.com>
Thu, 7 Jul 2016 05:37:53 +0000 (07:37 +0200)
The current implementation calls `string.Concat(object, object)`, which
results in a 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/953d38321f817dffe18261ce77d508947ed4b4fb

src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs

index 9861bcb..161de35 100644 (file)
@@ -852,7 +852,7 @@ namespace System.Reflection.Emit {
             ThrowIfCreated();
 
             // form the value class name
-            strValueClassName = ModuleBuilderData.MULTI_BYTE_VALUE_CLASS + size;
+            strValueClassName = ModuleBuilderData.MULTI_BYTE_VALUE_CLASS + size.ToString();
 
             // Is this already defined in this module?
             Type temp = m_module.FindTypeBuilderWithName(strValueClassName, false);