Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee9205d

Browse files
stephentoubMihaZupan
authored andcommitted
Improve WebUtility.HtmlEncode / UrlEncode performance (dotnet#103737)
* Improve WebUtility.HtmlEncode / UrlEncode performance- For HtmlEncode, vectorize IndexOfHtmlEncodingChars. Using SearchValues, we can efficiently search for the first ASCII encoding char or the first non-ASCII char, and only then fall back to a scalar loop.- For HtmlEncode, reduce branching by using a more efficient check to determine whether the ASCII characters need to be encoded.- For UrlEncode, rather than UTF8-encoding into a new byte[], %-encoding in-place in that, and then creating a string from that, we can use string.Create and just do all the encoding in that buffer.- For UrlEncode, use SearchValues to vectorize the search for the first non-safe char. Also move the check for ' ' to be inside the if for non-safe char.- For UrlEncode, use SearchValues to optimize the check for whether an individual character is part of the set (via Contains).- Simplify IsUrlSafeChar. Rather than multiple checks, one of which is a bitmap, just have a bitmap.- Remove some leading IsNullOrEmpty checks. Null/empty inputs should be rare, and they're now handled implicitly as part of the subsequent loops.* Update src/libraries/System.Private.CoreLib/src/System/Net/WebUtility.csCo-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>---------Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
1 parent25a0d84 commitee9205d

File tree

1 file changed

+137
-176
lines changed

1 file changed

+137
-176
lines changed

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp