2005-05-26 Ben Maurer <bmaurer@ximian.com>
authorBen Maurer <benm@mono-cvs.ximian.com>
Thu, 26 May 2005 20:14:26 +0000 (20:14 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Thu, 26 May 2005 20:14:26 +0000 (20:14 -0000)
* StringBuilder.cs: Remove = null inits on fields, saves a few
instructions. When we compare _cached_str == _str, we are only
interested in pointer based equality, so just do that.

svn path=/trunk/mcs/; revision=45073

mcs/class/corlib/System.Text/ChangeLog
mcs/class/corlib/System.Text/StringBuilder.cs

index 394bd2e8c787246be126149591d104402dda1624..d6f2c381974f60405afb358159d7fa9531ff0802 100755 (executable)
@@ -1,3 +1,9 @@
+2005-05-26  Ben Maurer  <bmaurer@ximian.com>
+
+       * StringBuilder.cs: Remove = null inits on fields, saves a few
+       instructions. When we compare _cached_str == _str, we are only
+       interested in pointer based equality, so just do that.
+
 2005-05-06  Ben Maurer  <bmaurer@ximian.com>
 
        * StringBuilder.cs (InternalEnsureCapacity): It is possible that
index 9c229bfdeb7db1b426f8ef60aafa76fdf3096b0f..8be44d6e0e45a404fa5f41500c332d073efe236e 100644 (file)
@@ -45,8 +45,8 @@ namespace System.Text {
        public sealed class StringBuilder 
        {
                private int _length;
-               private string _str = null;
-               private string _cached_str = null;
+               private string _str;
+               private string _cached_str;
                
                private int _maxCapacity = Int32.MaxValue;
                private const int constDefaultCapacity = 16;
@@ -639,8 +639,7 @@ namespace System.Text {
        
                private void InternalEnsureCapacity (int size) 
                {
-                       if (size > _str.Length || _cached_str == _str) 
-                       {
+                       if (size > _str.Length || (object) _cached_str == (object) _str) {
                                int capacity = _str.Length;
 
                                // Try double buffer, if that doesn't work, set the length as capacity
@@ -649,7 +648,7 @@ namespace System.Text {
                                        // The first time a string is appended, we just set _cached_str
                                        // and _str to it. This allows us to do some optimizations.
                                        // Below, we take this into account.
-                                       if (_cached_str == _str && capacity < constDefaultCapacity)
+                                       if ((object) _cached_str == (object) _str && capacity < constDefaultCapacity)
                                                capacity = constDefaultCapacity;
                                        
                                        capacity = capacity << 1;