From ffcabe4eb28c4ba960b6e7ceb692d6aec0ee8941 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 9 Mar 2023 17:13:07 +0700 Subject: Remove unnecessary methods --- crypto/src/util/io/Streams.cs | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/crypto/src/util/io/Streams.cs b/crypto/src/util/io/Streams.cs index b975d03bd..69f390646 100644 --- a/crypto/src/util/io/Streams.cs +++ b/crypto/src/util/io/Streams.cs @@ -63,9 +63,9 @@ namespace Org.BouncyCastle.Utilities.IO await WriteAsync(destination, new ReadOnlyMemory(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false); } #else - while ((bytesRead = await ReadAsync(source, buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0) + while ((bytesRead = await source.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false)) != 0) { - await WriteAsync(destination, buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false); + await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false); } #endif } @@ -140,17 +140,6 @@ namespace Org.BouncyCastle.Utilities.IO return buf.ToArray(); } - public static Task ReadAsync(Stream source, byte[] buffer, int offset, int count) - { - return source.ReadAsync(buffer, offset, count); - } - - public static Task ReadAsync(Stream source, byte[] buffer, int offset, int count, - CancellationToken cancellationToken) - { - return source.ReadAsync(buffer, offset, count, cancellationToken); - } - #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public static ValueTask ReadAsync(Stream source, Memory buffer, CancellationToken cancellationToken = default) @@ -158,11 +147,11 @@ namespace Org.BouncyCastle.Utilities.IO if (MemoryMarshal.TryGetArray(buffer, out ArraySegment array)) { return new ValueTask( - ReadAsync(source, array.Array!, array.Offset, array.Count, cancellationToken)); + source.ReadAsync(array.Array!, array.Offset, array.Count, cancellationToken)); } byte[] sharedBuffer = new byte[buffer.Length]; - var readTask = ReadAsync(source, sharedBuffer, 0, buffer.Length, cancellationToken); + var readTask = source.ReadAsync(sharedBuffer, 0, buffer.Length, cancellationToken); return FinishReadAsync(readTask, sharedBuffer, buffer); } @@ -227,17 +216,6 @@ namespace Org.BouncyCastle.Utilities.IO throw new ArgumentOutOfRangeException("count"); } - public static Task WriteAsync(Stream destination, byte[] buffer, int offset, int count) - { - return destination.WriteAsync(buffer, offset, count); - } - - public static Task WriteAsync(Stream destination, byte[] buffer, int offset, int count, - CancellationToken cancellationToken) - { - return destination.WriteAsync(buffer, offset, count, cancellationToken); - } - #if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER public static ValueTask WriteAsync(Stream destination, ReadOnlyMemory buffer, CancellationToken cancellationToken = default) @@ -245,11 +223,11 @@ namespace Org.BouncyCastle.Utilities.IO if (MemoryMarshal.TryGetArray(buffer, out ArraySegment array)) { return new ValueTask( - WriteAsync(destination, array.Array!, array.Offset, array.Count, cancellationToken)); + destination.WriteAsync(array.Array!, array.Offset, array.Count, cancellationToken)); } byte[] sharedBuffer = buffer.ToArray(); - var writeTask = WriteAsync(destination, sharedBuffer, 0, buffer.Length, cancellationToken); + var writeTask = destination.WriteAsync(sharedBuffer, 0, buffer.Length, cancellationToken); return new ValueTask(FinishWriteAsync(writeTask, sharedBuffer)); } -- cgit 1.4.1