summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-06-09 21:39:17 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-06-09 21:39:17 +0700
commitc6ba5170272dfa4470af11a3ff0fef99a22b1a31 (patch)
tree0663d7c0250db2aa3a3f93e64818505e7036d664
parentOverload AddObject for Asn1Object (diff)
downloadBouncyCastle.NET-ed25519-c6ba5170272dfa4470af11a3ff0fef99a22b1a31.tar.xz
New PipeAll with explicit buffer size
- increase default buffer size
-rw-r--r--crypto/src/util/io/Streams.cs22
1 files changed, 18 insertions, 4 deletions
diff --git a/crypto/src/util/io/Streams.cs b/crypto/src/util/io/Streams.cs
index 506b2489f..a86367e56 100644
--- a/crypto/src/util/io/Streams.cs
+++ b/crypto/src/util/io/Streams.cs
@@ -5,7 +5,7 @@ namespace Org.BouncyCastle.Utilities.IO
 {
 	public sealed class Streams
 	{
-		private const int BufferSize = 512;
+		private const int BufferSize = 4096;
 
 		private Streams()
 		{
@@ -51,10 +51,24 @@ namespace Org.BouncyCastle.Utilities.IO
 			return totalRead;
 		}
 
-		public static void PipeAll(Stream inStr, Stream outStr)
+        /// <summary>Write the full contents of inStr to the destination stream outStr.</summary>
+        /// <param name="inStr">Source stream.</param>
+        /// <param name="outStr">Destination stream.</param>
+        /// <exception cref="IOException">In case of IO failure.</exception>
+        public static void PipeAll(Stream inStr, Stream outStr)
 		{
-			byte[] bs = new byte[BufferSize];
-			int numRead;
+            PipeAll(inStr, outStr, BufferSize);
+        }
+
+        /// <summary>Write the full contents of inStr to the destination stream outStr.</summary>
+        /// <param name="inStr">Source stream.</param>
+        /// <param name="outStr">Destination stream.</param>
+        /// <param name="bufferSize">The size of temporary buffer to use.</param>
+        /// <exception cref="IOException">In case of IO failure.</exception>
+        public static void PipeAll(Stream inStr, Stream outStr, int bufferSize)
+        {
+            byte[] bs = new byte[bufferSize];
+            int numRead;
 			while ((numRead = inStr.Read(bs, 0, bs.Length)) > 0)
 			{
 				outStr.Write(bs, 0, numRead);