Skip to content

Commit

Permalink
Use string.Equals over string.Compare for improved performance (#9724)
Browse files Browse the repository at this point in the history
  • Loading branch information
h3xds1nz authored Oct 3, 2024
1 parent 0d959af commit cae5cef
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ internal bool AreTypeAndSubTypeEqual(ContentType contentType, bool allowParamete
// safe comparison because the _type and _subType strings have been restricted to
// ASCII characters, digits, and a small set of symbols. This is not a safe comparison
// for the broader set of strings that have not been restricted in the same way.
result = (String.Compare(_type, contentType.TypeComponent, StringComparison.OrdinalIgnoreCase) == 0 &&
String.Compare(_subType, contentType.SubTypeComponent, StringComparison.OrdinalIgnoreCase) == 0);
result = string.Equals(_type, contentType.TypeComponent, StringComparison.OrdinalIgnoreCase) &&
string.Equals(_subType, contentType.SubTypeComponent, StringComparison.OrdinalIgnoreCase);
}
return result;
}
Expand Down

0 comments on commit cae5cef

Please # to comment.