Author: vitek Date: Thu Jan 31 14:58:07 2008 New Revision: 617280 URL: http://svn.apache.org/viewvc?rev=617280&view=rev Log:
2008-01-31 Travis Vitek <[EMAIL PROTECTED]> Merged rev 617251 and 617276 from trunk. 2008-01-31 Travis Vitek <[EMAIL PROTECTED]> STDCXX-231 * include/string (clear): Avoid deallocating string body unless necessary. * include/string.cc (replace): Ditto. * include/istream.cc (getline): Call clear () instead of erase() to avoid unnecessary overhead. 2008-01-31 Travis Vitek <[EMAIL PROTECTED]> * tests/regress/21.string.stdcxx-231.cpp: Added regression test for STDCXX-231. Added: stdcxx/branches/4.2.x/tests/regress/21.string.stdcxx-231.cpp - copied unchanged from r617276, stdcxx/trunk/tests/regress/21.string.stdcxx-231.cpp Modified: stdcxx/branches/4.2.x/include/istream.cc stdcxx/branches/4.2.x/include/string stdcxx/branches/4.2.x/include/string.cc Modified: stdcxx/branches/4.2.x/include/istream.cc URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/istream.cc?rev=617280&r1=617279&r2=617280&view=diff ============================================================================== --- stdcxx/branches/4.2.x/include/istream.cc (original) +++ stdcxx/branches/4.2.x/include/istream.cc Thu Jan 31 14:58:07 2008 @@ -877,7 +877,7 @@ if (__ipfx) { - __str.erase (); + __str.clear (); // carefuly handle arithmetic overflow _SizeT __n = __str.max_size (); Modified: stdcxx/branches/4.2.x/include/string URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/string?rev=617280&r1=617279&r2=617280&view=diff ============================================================================== --- stdcxx/branches/4.2.x/include/string (original) +++ stdcxx/branches/4.2.x/include/string Thu Jan 31 14:58:07 2008 @@ -266,7 +266,12 @@ void reserve (size_type = 0); void clear () { - _C_unlink (_C_nullref ()->data ()); + if (size_type (1) < size_type (_C_pref ()->_C_get_ref ())) + _C_unlink (_C_nullref ()->data ()); + else { + traits_type::assign (_C_data [0], value_type ()); + _C_pref ()->_C_size._C_size = 0; + } } bool empty () const { Modified: stdcxx/branches/4.2.x/include/string.cc URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/string.cc?rev=617280&r1=617279&r2=617280&view=diff ============================================================================== --- stdcxx/branches/4.2.x/include/string.cc (original) +++ stdcxx/branches/4.2.x/include/string.cc Thu Jan 31 14:58:07 2008 @@ -379,7 +379,7 @@ } else { // special case a substitution that leaves the string empty. - _C_unlink (_C_nullref ()->data ()); + clear (); } return *this; @@ -452,8 +452,8 @@ } } else { - // construct the empty string - _C_unlink (_C_nullref ()->data ()); + // special case a substitution that leaves the string empty. + clear (); } return *this;