Skip to content

Commit ecb9d6e

Browse files
committed
code refactor to remove Task.Run on CPU bound operation
1 parent 49a181a commit ecb9d6e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System.IO;
@@ -63,7 +63,7 @@ public async Task<ReadFragmentResult<T>> ReadFragmentAsync<T>(TextReader input,
6363
return default;
6464
}
6565

66-
return await ReadFragmentAsync<T>(jsonNode, version, settings);
66+
return ReadFragment<T>(jsonNode, version, settings);
6767
}
6868

6969
/// <summary>
@@ -86,9 +86,9 @@ public async Task<ReadResult> ReadAsync(JsonNode jsonNode, OpenApiReaderSettings
8686
}
8787

8888
/// <inheritdoc/>
89-
public async Task<ReadFragmentResult<T>> ReadFragmentAsync<T>(JsonNode input, OpenApiSpecVersion version, OpenApiReaderSettings settings = null) where T : IOpenApiElement
89+
public ReadFragmentResult<T> ReadFragment<T>(JsonNode input, OpenApiSpecVersion version, OpenApiReaderSettings settings = null) where T : IOpenApiElement
9090
{
91-
return await OpenApiReaderRegistry.DefaultReader.ReadFragmentAsync<T>(input, version, settings);
91+
return OpenApiReaderRegistry.DefaultReader.ReadFragment<T>(input, version, settings);
9292
}
9393
}
9494
}

src/Microsoft.OpenApi/Interfaces/IOpenApiReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System.IO;
@@ -48,6 +48,6 @@ public interface IOpenApiReader
4848
/// <param name="version">Version of the OpenAPI specification that the fragment conforms to.</param>
4949
/// <param name="settings">The OpenApiReader settings.</param>
5050
/// <returns>Instance of newly created IOpenApiElement.</returns>
51-
Task<ReadFragmentResult<T>> ReadFragmentAsync<T>(JsonNode input, OpenApiSpecVersion version, OpenApiReaderSettings settings = null) where T: IOpenApiElement;
51+
ReadFragmentResult<T> ReadFragment<T>(JsonNode input, OpenApiSpecVersion version, OpenApiReaderSettings settings = null) where T: IOpenApiElement;
5252
}
5353
}

src/Microsoft.OpenApi/Reader/OpenApiJsonReader.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System.IO;
@@ -139,13 +139,13 @@ public async Task<ReadFragmentResult<T>> ReadFragmentAsync<T>(TextReader input,
139139
return default;
140140
}
141141

142-
return await ReadFragmentAsync<T>(jsonNode, version, settings);
142+
return ReadFragment<T>(jsonNode, version, settings);
143143
}
144144

145145
/// <inheritdoc/>
146-
public async Task<ReadFragmentResult<T>> ReadFragmentAsync<T>(JsonNode input,
147-
OpenApiSpecVersion version,
148-
OpenApiReaderSettings settings = null) where T : IOpenApiElement
146+
public ReadFragmentResult<T> ReadFragment<T>(JsonNode input,
147+
OpenApiSpecVersion version,
148+
OpenApiReaderSettings settings = null) where T : IOpenApiElement
149149
{
150150
var diagnostic = new OpenApiDiagnostic();
151151
settings ??= new OpenApiReaderSettings();

0 commit comments

Comments
 (0)