TimeZoneInfo.StringSerializer: Avoid some unnecessary allocations (dotnet/coreclr...
authorJustin Van Patten <jvp@justinvp.com>
Tue, 3 Jan 2017 20:00:46 +0000 (12:00 -0800)
committerTarek Mahmoud Sayed <tarekms@microsoft.com>
Tue, 3 Jan 2017 20:00:46 +0000 (12:00 -0800)
commitd2a1bf1f6ccaf784dfbc553518f74bf2f76afd60
treef8e58a8594090db67dfbb262797ee7b44330d626
parent6cc6a63615e64fa256c2b9bac191683d349f202f
TimeZoneInfo.StringSerializer: Avoid some unnecessary allocations (dotnet/coreclr#8783)

Instead of using multiple calls to `string.Replace` to escape reserved
chars before appending to a `StringBuilder`, do the replacing while
appending the chars directly to the `StringBuilder`.

Also, append numbers/dates directly instead of running it through the
escape method, as these Invariant-formatted strings will not contain any
chars that need to be escaped.

Commit migrated from https://github.com/dotnet/coreclr/commit/1d15b16516ebc580d88d179e8cdf800bbeac1b4b
src/coreclr/src/mscorlib/src/System/TimeZoneInfo.StringSerializer.cs