forked from dotnet/aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using SearchValues in ContentDispositionHeaderValue (dotnet#55039)
* Using SearchValues in ContentDispositionHeaderValue Updating current Encode5987 method to use SearchValues and IndexOfAny to encode the FileNameStar property. Adding unit tests and a benchmark to measure the before-after performance * Removing if-else case for the encoding parts with the rune. * Correcting the size of the temp char buffer allocation * Review feedback * Adding test for inputs that does not fit on a stacksize * Using a for loop instead of a while loop for processing toHexEscape * Using ref struct string interpolation with string builder * Using a const for the stackallocted buffer sizes. * Remove unneeded span * Using Rune to encode/decode non ascii characters * With custom utf8 and hex encoding combined * Update src/Http/Headers/src/ContentDispositionHeaderValue.cs Co-authored-by: Günther Foidl <gue@korporal.at> --------- Co-authored-by: ladeak <ladeak87@windowslive.com> Co-authored-by: Günther Foidl <gue@korporal.at>
- Loading branch information
1 parent
8660e3a
commit 84af599
Showing
3 changed files
with
128 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Http/Http/perf/Microbenchmarks/ContentDispositionHeaderValueBenchmarks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using Microsoft.Net.Http.Headers; | ||
|
||
namespace Microsoft.AspNetCore.Http; | ||
|
||
public class ContentDispositionHeaderValueBenchmarks | ||
{ | ||
private readonly ContentDispositionHeaderValue _contentDisposition = new ContentDispositionHeaderValue("inline"); | ||
|
||
[Benchmark] | ||
public void FileNameStarEncoding() => _contentDisposition.FileNameStar = "My TypicalFilename 2024 04 09 08:00:00.dat"; | ||
|
||
[Benchmark] | ||
public void FileNameStarNoEncoding() => _contentDisposition.FileNameStar = "My_TypicalFilename_2024_04_09-08_00_00.dat"; | ||
|
||
} |