Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing "await" prefix or "Async" suffix in "async" methods #6787

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

marco-carvalho
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the gui Related to Ryujinx.Ui label May 8, 2024
@ryujinx-mako ryujinx-mako bot requested review from AcK77, emmauss, TSRBerry and a team May 8, 2024 19:53
@@ -59,7 +59,7 @@ public static IMemoryOwner<byte> StreamToRentedMemory(Stream input)

public static async Task<byte[]> StreamToBytesAsync(Stream input, CancellationToken cancellationToken = default)
{
using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
await using MemoryStream stream = MemoryStreamManager.Shared.GetStream();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no point in async-disposing of a MemoryStream, it just adds overhead around calling Dispose().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -479,7 +479,7 @@ private async Task UpdateAmiiboPreview(string imageUrl)
if (response.IsSuccessStatusCode)
{
byte[] amiiboPreviewBytes = await response.Content.ReadAsByteArrayAsync();
using MemoryStream memoryStream = new(amiiboPreviewBytes);
await using MemoryStream memoryStream = new(amiiboPreviewBytes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted elsewhere, async-disposing a MemoryStream only adds overhead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -97,7 +97,7 @@ public static string ReadAllText(Assembly assembly, string filename)

public async static Task<string> ReadAllTextAsync(Assembly assembly, string filename)
{
using var stream = GetStream(assembly, filename);
await using var stream = GetStream(assembly, filename);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Streams returned by GetStream() -> Assembly.GetManifestResourceStream() are based on UnmanagedMemoryStream, and disposing asynchronously only adds overhead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui Related to Ryujinx.Ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants