Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse StringBuilders in EventArgsFormatting
While I was editing in this area I noticed that the calling pattern around StringBuilders in FormatEventMessage looked allocatey. Instead of creating two throwaway StringBuilders to format a single message, 1. Grab a ReusableStringBuilder 2. Reuse the builder between "construct format string" and "get final message". We chose ReusableStringBuilder over StringBuilderCache because logging sometimes creates strings that are _much_ larger than the 512 character limit of SBC. That also reduces the need to prereserve a size: the process-wide pool's elements should be pretty big already. See dotnet#2697 (comment) for stats on string length.
- Loading branch information