From 29e58641048330e3ec577f731b5ece54fd3ff43f Mon Sep 17 00:00:00 2001 From: Benjamin Hodgson Date: Mon, 19 Feb 2018 14:20:05 +0000 Subject: [PATCH] Optimise HtmlEncode to produce less garbage do the same optimisation for HtmlDecode remove now-unneeded reference Add tests for new ValueStringBuilder methods Signed-off-by: dotnet-bot-corefx-mirror --- .../shared/System/Text/ValueStringBuilder.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs index d41bea0..1e33bdb 100644 --- a/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs @@ -22,6 +22,13 @@ namespace System.Text _pos = 0; } + public ValueStringBuilder(int initialCapacity) + { + _arrayToReturnToPool = ArrayPool.Shared.Rent(initialCapacity); + _chars = _arrayToReturnToPool; + _pos = 0; + } + public int Length { get => _pos; -- 2.7.4