Author: vitek
Date: Thu Jan 31 13:42:59 2008
New Revision: 617251
URL: http://svn.apache.org/viewvc?rev=617251&view=rev
Log:
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.
Modified:
stdcxx/trunk/include/istream.cc
stdcxx/trunk/include/string
stdcxx/trunk/include/string.cc
Modified: stdcxx/trunk/include/istream.cc
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/include/istream.cc?rev=617251&r1=617250&r2=617251&view=diff
==============================================================================
--- stdcxx/trunk/include/istream.cc (original)
+++ stdcxx/trunk/include/istream.cc Thu Jan 31 13:42:59 2008
@@ -877,7 +877,7 @@
if (__ipfx) {
- __str.erase ();
+ __str.clear ();
// carefuly handle arithmetic overflow
_SizeT __n = __str.max_size ();
Modified: stdcxx/trunk/include/string
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/include/string?rev=617251&r1=617250&r2=617251&view=diff
==============================================================================
--- stdcxx/trunk/include/string (original)
+++ stdcxx/trunk/include/string Thu Jan 31 13:42:59 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/trunk/include/string.cc
URL:
http://svn.apache.org/viewvc/stdcxx/trunk/include/string.cc?rev=617251&r1=617250&r2=617251&view=diff
==============================================================================
--- stdcxx/trunk/include/string.cc (original)
+++ stdcxx/trunk/include/string.cc Thu Jan 31 13:42:59 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;