Skip to content

Commit 9b91130

Browse files
committed
Combine two checks using TryGetValue() for efficiency
1 parent 5f90def commit 9b91130

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Microsoft.OpenApi.Readers/V2/OpenApiResponseDeserializer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ private static void ProcessProduces(MapNode mapNode, OpenApiResponse response, P
9292
foreach (var produce in produces)
9393
{
9494

95-
if (response.Content.ContainsKey(produce) && response.Content[produce] != null)
95+
if (response.Content.TryGetValue(produce, out var produceValue))
9696
{
9797
if (schema != null)
9898
{
99-
response.Content[produce].Schema = schema;
100-
ProcessAnyFields(mapNode, response.Content[produce], _mediaTypeAnyFields);
99+
produceValue.Schema = schema;
100+
ProcessAnyFields(mapNode, produceValue, _mediaTypeAnyFields);
101101
}
102102
}
103103
else

0 commit comments

Comments
 (0)