Reduce string allocation in DiagnosticCounter.GetMetadataString (#25219)
authorStephen Toub <stoub@microsoft.com>
Fri, 21 Jun 2019 04:36:42 +0000 (00:36 -0400)
committerGitHub <noreply@github.com>
Fri, 21 Jun 2019 04:36:42 +0000 (00:36 -0400)
commit99c30f13c1f64180a2524e6160d374f366c01719
treecad4c63e4b8b73e2661ea42a08ff6199036e911c
parentf77a8bee633f8fae4b3ee85afff619e11226d79b
Reduce string allocation in DiagnosticCounter.GetMetadataString (#25219)

When the _metadata dictionary contains a single key/value pair, the method ends up allocating an unnecessary StringBuilder, char[] beneath it, and input string.

When the _metadata dictionary contains more key/value pairs, the method ends up allocating an unnecessary string per key/value pair.
src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/DiagnosticCounter.cs