mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-11 09:23:04 +00:00
Use ValueTask instead of Task where possible
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user