summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2019-08-01 20:24:04 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2019-08-01 20:24:04 +0700
commit3fd3578972d69cabec38a060f1193f8c3138cc36 (patch)
treed7f40ffd5fa504b81e30f694541bf6c8540fb53f
parentPCL fixes (diff)
downloadBouncyCastle.NET-ed25519-3fd3578972d69cabec38a060f1193f8c3138cc36.tar.xz
Refactor ToString()
-rw-r--r--crypto/src/util/collections/CollectionUtilities.cs17
1 files changed, 6 insertions, 11 deletions
diff --git a/crypto/src/util/collections/CollectionUtilities.cs b/crypto/src/util/collections/CollectionUtilities.cs
index cac158226..e0c79bdf4 100644
--- a/crypto/src/util/collections/CollectionUtilities.cs
+++ b/crypto/src/util/collections/CollectionUtilities.cs
@@ -49,23 +49,18 @@ namespace Org.BouncyCastle.Utilities.Collections
 
         public static string ToString(IEnumerable c)
         {
-            StringBuilder sb = new StringBuilder("[");
-
             IEnumerator e = c.GetEnumerator();
+            if (!e.MoveNext())
+                return "[]";
 
-            if (e.MoveNext())
+            StringBuilder sb = new StringBuilder("[");
+            sb.Append(e.Current.ToString());
+            while (e.MoveNext())
             {
+                sb.Append(", ");
                 sb.Append(e.Current.ToString());
-
-                while (e.MoveNext())
-                {
-                    sb.Append(", ");
-                    sb.Append(e.Current.ToString());
-                }
             }
-
             sb.Append(']');
-
             return sb.ToString();
         }
     }