summary refs log tree commit diff
path: root/crypto/src/util/collections/CollectionUtilities.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/util/collections/CollectionUtilities.cs')
-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();
         }
     }