Skip to content

Avoid StringSegment conversions #56533

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace Microsoft.Net.Http.Headers;
/// </summary>
public class StringWithQualityHeaderValueComparer : IComparer<StringWithQualityHeaderValue>
{
private static readonly StringSegment Any = new("*");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might call it "AnyQuality", but I don't feel strongly about it.


private StringWithQualityHeaderValueComparer()
{
}
Expand Down Expand Up @@ -55,11 +57,11 @@ public int Compare(

if (!StringSegment.Equals(stringWithQuality1.Value, stringWithQuality2.Value, StringComparison.OrdinalIgnoreCase))
{
if (StringSegment.Equals(stringWithQuality1.Value, "*", StringComparison.Ordinal))
if (StringSegment.Equals(stringWithQuality1.Value, Any, StringComparison.Ordinal))
{
return -1;
}
else if (StringSegment.Equals(stringWithQuality2.Value, "*", StringComparison.Ordinal))
else if (StringSegment.Equals(stringWithQuality2.Value, Any, StringComparison.Ordinal))
{
return 1;
}
Expand Down
Loading