Use ValueTask instead of Task where possible

This commit is contained in:
Alexey Golub
2020-07-18 15:57:51 +03:00
parent ac64d9943a
commit ba66b52fa4
16 changed files with 52 additions and 51 deletions

View File

@@ -8,7 +8,7 @@ namespace DiscordChatExporter.Domain.Internal.Extensions
internal static class HttpClientExtensions
{
// HACK: ConfigureAwait() is crucial here to enable sync-over-async in HtmlMessageWriter
public static async Task DownloadAsync(this HttpClient httpClient, string uri, string outputFilePath)
public static async ValueTask DownloadAsync(this HttpClient httpClient, string uri, string outputFilePath)
{
await using var input = await httpClient.GetStreamAsync(uri).ConfigureAwait(false);
var output = File.Create(outputFilePath);
@@ -17,7 +17,7 @@ namespace DiscordChatExporter.Domain.Internal.Extensions
await output.DisposeAsync().ConfigureAwait(false);
}
public static async Task<JsonElement> ReadAsJsonAsync(this HttpContent content)
public static async ValueTask<JsonElement> ReadAsJsonAsync(this HttpContent content)
{
await using var stream = await content.ReadAsStreamAsync();
using var doc = await JsonDocument.ParseAsync(stream);