2007-04-24 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / corlib / System.IO / MemoryStream.cs
index 1e70a8e9a83a681fccde7d7dba15ca2c157bf5bb..fa37add12026a3590b0800ab2bc6b28c1a056847 100644 (file)
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices;
 namespace System.IO
 {
        [Serializable]
-       [MonoTODO ("Fix serialization compatibility with MS.NET")]
+       [MonoTODO ("Serialization format not compatible with .NET")]
        public class MemoryStream : Stream
        {
                bool canWrite;
@@ -336,15 +336,12 @@ namespace System.IO
                                throw new ArgumentOutOfRangeException ();
 
                        int newSize = (int) value + initialIndex;
-                       if (newSize > capacity) {
+                       if (newSize > capacity)
                                Capacity = CalculateNewCapacity (newSize);
-                       }
-                       else if (newSize < length) {
+                       else if (newSize < length)
                                // zeroize present data (so we don't get it 
                                // back if we expand the stream using Seek)
-                               for (int i = newSize; i < length; i++)
-                                       Buffer.SetByte (internalBuffer, i, 0);
-                       }
+                               Array.Clear (internalBuffer, newSize, length - newSize);
 
                        length = newSize;
                        if (position > length)