From baa0c3f00f3f2989a8ca3837c69a1a8e4b7ea1ad 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 d41bea0be9d7..1e33bdb49b4d 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 @@ public ValueStringBuilder(Span initialBuffer) _pos = 0; } + public ValueStringBuilder(int initialCapacity) + { + _arrayToReturnToPool = ArrayPool.Shared.Rent(initialCapacity); + _chars = _arrayToReturnToPool; + _pos = 0; + } + public int Length { get => _pos;