Skip to content

Commit 00c5d3b

Browse files
Fix CodeQL suggestion
1 parent ccf70c4 commit 00c5d3b

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/AspNet/WebApi/src/Asp.Versioning.WebApi/System.Net.Http/HttpResponseMessageExtensions.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,9 @@ public static void WriteSunsetPolicy( this HttpResponseMessage response, SunsetP
4444

4545
private static void AddLinkHeaders( HttpResponseHeaders headers, IList<LinkHeaderValue> links )
4646
{
47-
ICollection<string> values;
48-
49-
if ( headers.TryGetValues( Link, out var existing ) )
50-
{
51-
values = existing is ICollection<string> collection && !collection.IsReadOnly ? collection : new List<string>( existing );
52-
}
53-
else
54-
{
55-
values = new List<string>( capacity: links.Count );
56-
}
47+
var values = headers.TryGetValues( Link, out var existing )
48+
? existing is ICollection<string> collection && !collection.IsReadOnly ? collection : new List<string>( existing )
49+
: new List<string>( capacity: links.Count );
5750

5851
for ( var i = 0; i < links.Count; i++ )
5952
{

0 commit comments

Comments
 (0)