Skip to content

Commit d5f7e5a

Browse files
Remove unrequired async/await
1 parent bbf5b3b commit d5f7e5a

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/ImageSharp/Formats/Png/PngEncoder.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ public void Encode<TPixel>(Image<TPixel> image, Stream stream)
7272
/// <param name="image">The <see cref="Image{TPixel}"/> to encode from.</param>
7373
/// <param name="stream">The <see cref="Stream"/> to encode the image data to.</param>
7474
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
75-
public async Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
75+
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
7676
where TPixel : unmanaged, IPixel<TPixel>
7777
{
78-
using (var encoder = new PngEncoderCore(image.GetMemoryAllocator(), image.GetConfiguration(), new PngEncoderOptions(this)))
79-
{
80-
await encoder.EncodeAsync(image, stream).ConfigureAwait(false);
81-
}
78+
using var encoder = new PngEncoderCore(image.GetMemoryAllocator(), image.GetConfiguration(), new PngEncoderOptions(this));
79+
return encoder.EncodeAsync(image, stream);
8280
}
8381
}
8482
}

src/ImageSharp/Image.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ public void Save(Stream stream, IImageEncoder encoder)
103103
/// </summary>
104104
/// <param name="stream">The stream to save the image to.</param>
105105
/// <param name="encoder">The encoder to save the image with.</param>
106-
/// <exception cref="System.ArgumentNullException">Thrown if the stream or encoder is null.</exception>
106+
/// <exception cref="ArgumentNullException">Thrown if the stream or encoder is null.</exception>
107107
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
108-
public async Task SaveAsync(Stream stream, IImageEncoder encoder)
108+
public Task SaveAsync(Stream stream, IImageEncoder encoder)
109109
{
110110
Guard.NotNull(stream, nameof(stream));
111111
Guard.NotNull(encoder, nameof(encoder));
112112
this.EnsureNotDisposed();
113113

114-
await this.AcceptVisitorAsync(new EncodeVisitor(encoder, stream)).ConfigureAwait(false);
114+
return this.AcceptVisitorAsync(new EncodeVisitor(encoder, stream));
115115
}
116116

117117
/// <summary>
@@ -179,9 +179,8 @@ public EncodeVisitor(IImageEncoder encoder, Stream stream)
179179
public void Visit<TPixel>(Image<TPixel> image)
180180
where TPixel : unmanaged, IPixel<TPixel> => this.encoder.Encode(image, this.stream);
181181

182-
public async Task VisitAsync<TPixel>(Image<TPixel> image)
183-
where TPixel : unmanaged, IPixel<TPixel>
184-
=> await this.encoder.EncodeAsync(image, this.stream).ConfigureAwait(false);
182+
public Task VisitAsync<TPixel>(Image<TPixel> image)
183+
where TPixel : unmanaged, IPixel<TPixel> => this.encoder.EncodeAsync(image, this.stream);
185184
}
186185
}
187186
}

0 commit comments

Comments
 (0)