+2008-06-01 Juraj Skripsky <js@hotfeet.ch>
+
+ * StringBuilder.cs (ToString): Use String.SubstringUnchecked instead
+ of String.Substring, as the former is guaranteed to create a new
+ string object. Fixes bug #395904.
+
2008-05-15 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* StringBuilder.cs: Resubmit uncritical parts of String cleanup patch
// If we only have a half-full buffer we return a new string.
if (_length < (_str.Length >> 1))
{
- _cached_str = _str.Substring(0, _length);
+ // use String.SubstringUnchecked instead of String.Substring
+ // as the former is guaranteed to create a new string object
+ _cached_str = _str.SubstringUnchecked (0, _length);
return _cached_str;
}
if (startIndex < 0 || length < 0 || startIndex > _length - length)
throw new ArgumentOutOfRangeException();
- return _str.Substring (startIndex, length);
+ // use String.SubstringUnchecked instead of String.Substring
+ // as the former is guaranteed to create a new string object
+ if (startIndex == 0 && length == _length)
+ return ToString ();
+ else
+ return _str.SubstringUnchecked (startIndex, length);
}
public int EnsureCapacity (int capacity)
+2008-06-01 Juraj Skripsky <js@hotfeet.ch>
+
+ * String.cs (Substring): Blocking bug #395904 has been fixed,
+ re-enable optimization.
+
2008-06-01 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* String.cs: Replace Split IndexOf
if (startIndex > this.length - length)
throw new ArgumentOutOfRangeException ("length", "startIndex + length > this.length");
#if NET_2_0
- // FIXME: this causes regressions in System.Xml
- /*
if (startIndex == 0 && length == this.length)
return this;
- */
#endif
return SubstringUnchecked (startIndex, length);
}
+ // This method is used by StringBuilder.ToString() and is expected to
+ // always create a new string object (or return String.Empty).
internal unsafe String SubstringUnchecked (int startIndex, int length)
{
if (length == 0)
+2008-06-01 Juraj Skripsky <js@hotfeet.ch>
+
+ * StringTest.cs (Substring2): Blocking bug #395904 has been fixed,
+ re-enable test.
+
2008-05-24 Andreas Nahr <ClassDevelopment@A-SoftTech.com>
* StringTest.cs: Comment out a test that currently fails by checking for
AssertEquals ("#3", "origina", s.Substring (0, s.Length - 1));
AssertEquals ("#4", s, s.Substring (0, s.Length));
#if NET_2_0
- // FIXME: enabling the fix for this causes regressions in System.Xml
- //AssertSame ("#5", s, s.Substring (0, s.Length));
+ AssertSame ("#5", s, s.Substring (0, s.Length));
#else
Assert ("#5", !object.ReferenceEquals (s, s.Substring (0, s.Length)));
#endif