- Notifications
You must be signed in to change notification settings - Fork5.1k
Use stackalloc char&byte arrays for decoding Url values in HttpUtiliy.ParseQueryString#102745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
TrayanZapryanov commentedMay 28, 2024
- Convert UrlDecoder to ref struct
- If Url is less than 256 characters, do no allocate char&byte arrays
- Replace substring operation with Span
Tagging subscribers to this area: @dotnet/ncl |
src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
TrayanZapryanov commentedMay 28, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Benchmark: [MemoryDiagnoser]publicclassHttpUtilityBenchmarks{privatestaticstringUnicodeStr=>newstring(new[]{'\u304a','\u75b2','\u308c','\u69d8','\u3067','\u3059'});privatestaticstringEncodedUnicodeStr=>HttpUtility.UrlEncode(UnicodeStr)+"="+HttpUtility.UrlEncode(UnicodeStr);[Benchmark(Baseline=true)]publicNameValueCollectionParseQueryString()=>HttpUtility.ParseQueryString("https://portal.azure.com/#@testgroup.onmicrosoft.com/dashboard/arm/subscriptions/111111-abac-4067-81ba-5ae054d891b5/"+"resourcegroups/dashboards/providers/microsoft.portal/dashboards/3456268-8630-60f7-aaac-eca38aca231");[Benchmark]publicNameValueCollectionParseQueryString_Mix()=>HttpUtility.ParseQueryString("ReturnUrl=http%3a%2f%2flocalhost%2flogin%2fauthenticate%3fReturnUrl%3dhttp%3a%2f%2flocalhost%2fsecured_area%26__provider__%3dgoogle");[Benchmark]publicNameValueCollectionParseQueryString_Unicode()=>HttpUtility.ParseQueryString(EncodedUnicodeStr);} Results: Before:
PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is one weird class.
Thanks for taking care of these low-hanging fruit
src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.