Fixup nullable (#22861)

This commit is contained in:
Pranav K 2020-06-12 08:32:41 -07:00 committed by GitHub
parent 69bba6a5a9
commit c30638b829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -39,7 +39,7 @@ namespace Microsoft.Net.Http.Headers
} }
else else
{ {
parameters!.Add(new NameValueHeaderValue(QualityName, qualityString)); parameters.Add(new NameValueHeaderValue(QualityName, qualityString));
} }
} }
else else
@ -52,15 +52,14 @@ namespace Microsoft.Net.Http.Headers
} }
} }
internal static double? GetQuality(IList<NameValueHeaderValue> parameters) internal static double? GetQuality(IList<NameValueHeaderValue>? parameters)
{ {
var qualityParameter = NameValueHeaderValue.Find(parameters, QualityName); var qualityParameter = NameValueHeaderValue.Find(parameters, QualityName);
if (qualityParameter != null) if (qualityParameter != null)
{ {
// Note that the RFC requires decimal '.' regardless of the culture. I.e. using ',' as decimal // Note that the RFC requires decimal '.' regardless of the culture. I.e. using ',' as decimal
// separator is considered invalid (even if the current culture would allow it). // separator is considered invalid (even if the current culture would allow it).
if (TryParseQualityDouble(qualityParameter.Value, 0, out var qualityValue, out var length)) if (TryParseQualityDouble(qualityParameter.Value, 0, out var qualityValue, out _))
{ {
return qualityValue; return qualityValue;
} }
@ -703,7 +702,8 @@ namespace Microsoft.Net.Http.Headers
var backSlashCount = CountAndCheckCharactersNeedingBackslashesWhenEncoding(input); var backSlashCount = CountAndCheckCharactersNeedingBackslashesWhenEncoding(input);
// 2 for quotes // 2 for quotes
return string.Create(input.Length + backSlashCount + 2, input, (span, segment) => { return string.Create(input.Length + backSlashCount + 2, input, (span, segment) =>
{
// Helps to elide the bounds check for span[0] // Helps to elide the bounds check for span[0]
span[span.Length - 1] = span[0] = '\"'; span[span.Length - 1] = span[0] = '\"';

View File

@ -206,7 +206,7 @@ namespace Microsoft.Net.Http.Headers
/// </summary> /// </summary>
public double? Quality public double? Quality
{ {
get { return HeaderUtilities.GetQuality(Parameters); } get => HeaderUtilities.GetQuality(_parameters);
set set
{ {
HeaderUtilities.ThrowIfReadOnly(IsReadOnly); HeaderUtilities.ThrowIfReadOnly(IsReadOnly);