Readability improvement in MemoryStream (#21710)
authorMarek Safar <marek.safar@gmail.com>
Mon, 31 Dec 2018 05:58:29 +0000 (06:58 +0100)
committerJan Kotas <jkotas@microsoft.com>
Mon, 31 Dec 2018 05:58:29 +0000 (19:58 -1000)
src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs

index 9bac0d8..8ca162b 100644 (file)
@@ -150,11 +150,7 @@ namespace System.IO
 
             if (value > _capacity)
             {
-                int newCapacity = value;
-                if (newCapacity < 256)
-                {
-                    newCapacity = 256;
-                }
+                int newCapacity = Math.Max(value, 256);
 
                 // We are ok with this overflowing since the next statement will deal
                 // with the cases where _capacity*2 overflows.
@@ -167,7 +163,7 @@ namespace System.IO
                 // And we want to give the user the value that they asked for
                 if ((uint)(_capacity * 2) > Array.MaxByteArrayLength)
                 {
-                    newCapacity = value > Array.MaxByteArrayLength ? value : Array.MaxByteArrayLength;
+                    newCapacity = Math.Max(value, Array.MaxByteArrayLength);
                 }
 
                 Capacity = newCapacity;