From 804a6f0dbc7b03e137c0b8323fd6d48943d4b9ff Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 14 Dec 2023 12:32:52 -0800 Subject: [PATCH] Use accelerated IndexOfAny in one more case --- src/Markdig/Renderers/HtmlRenderer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Markdig/Renderers/HtmlRenderer.cs b/src/Markdig/Renderers/HtmlRenderer.cs index 27b5d361..085a4e97 100644 --- a/src/Markdig/Renderers/HtmlRenderer.cs +++ b/src/Markdig/Renderers/HtmlRenderer.cs @@ -144,6 +144,8 @@ public HtmlRenderer WriteEscape(string content, int offset, int length, bool sof return this; } + private static readonly SearchValues s_escapedChars = SearchValues.Create("<>&\""); + /// /// Writes the content escaped for HTML. /// @@ -159,7 +161,7 @@ public void WriteEscape(ReadOnlySpan content, bool softEscape = false) { int indexOfCharToEscape = softEscape ? content.IndexOfAny('<', '&') - : content.IndexOfAny("<>&\""); + : content.IndexOfAny(s_escapedChars); if ((uint)indexOfCharToEscape >= (uint)content.Length) {