-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Changes from 2 commits
3d3f554
baaff04
b4eea8c
2872236
b3cc76d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
await input.CopyToAsync(stream, cancellationToken); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,8 +440,8 @@ private async Task<string> DownloadAmiiboJson() | |
|
||
try | ||
{ | ||
using FileStream dlcJsonStream = File.Create(_amiiboJsonPath, 4096, FileOptions.WriteThrough); | ||
dlcJsonStream.Write(Encoding.UTF8.GetBytes(amiiboJsonString)); | ||
await using FileStream dlcJsonStream = File.Create(_amiiboJsonPath, 4096, FileOptions.WriteThrough); | ||
await dlcJsonStream.WriteAsync(Encoding.UTF8.GetBytes(amiiboJsonString)); | ||
} | ||
catch (Exception exception) | ||
{ | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As noted elsewhere, async-disposing a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
Bitmap bitmap = new(memoryStream); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These
Stream
s returned byGetStream()
->Assembly.GetManifestResourceStream()
are based onUnmanagedMemoryStream
, and disposing asynchronously only adds overhead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done