Skip to content

Commit

Permalink
Use accelerated IndexOfAny in one more case
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcarbon committed Dec 14, 2023
1 parent 342e264 commit 804a6f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Markdig/Renderers/HtmlRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public HtmlRenderer WriteEscape(string content, int offset, int length, bool sof
return this;
}

private static readonly SearchValues<char> s_escapedChars = SearchValues.Create("<>&\"");

/// <summary>
/// Writes the content escaped for HTML.
/// </summary>
Expand All @@ -159,7 +161,7 @@ public void WriteEscape(ReadOnlySpan<char> content, bool softEscape = false)
{
int indexOfCharToEscape = softEscape
? content.IndexOfAny('<', '&')
: content.IndexOfAny("<>&\"");
: content.IndexOfAny(s_escapedChars);

if ((uint)indexOfCharToEscape >= (uint)content.Length)
{
Expand Down

0 comments on commit 804a6f0

Please sign in to comment.