mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-25 18:53:08 +08:00
sso_string_base.h (__sso_string_base<>::_M_assign): Simplify, avoid pointless reallocations.
2005-12-05 Paolo Carlini <pcarlini@suse.de> * include/ext/sso_string_base.h (__sso_string_base<>::_M_assign): Simplify, avoid pointless reallocations. From-SVN: r108063
This commit is contained in:
parent
53917868b8
commit
afe6d70550
@ -1,3 +1,8 @@
|
||||
2005-12-05 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/ext/sso_string_base.h (__sso_string_base<>::_M_assign):
|
||||
Simplify, avoid pointless reallocations.
|
||||
|
||||
2005-12-04 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/ext/sso_string_base.h (__sso_string_base<>::_M_reserve):
|
||||
|
@ -455,22 +455,22 @@ namespace __gnu_cxx
|
||||
{
|
||||
if (this != &__rcs)
|
||||
{
|
||||
size_type __size = __rcs._M_length();
|
||||
const size_type __rsize = __rcs._M_length();
|
||||
const size_type __capacity = _M_capacity();
|
||||
|
||||
_CharT* __tmp = _M_local_data;
|
||||
if (__size > size_type(_S_local_capacity))
|
||||
__tmp = _M_create(__size, size_type(0));
|
||||
if (__rsize > __capacity)
|
||||
{
|
||||
size_type __new_capacity = __rsize;
|
||||
_CharT* __tmp = _M_create(__new_capacity, __capacity);
|
||||
_M_dispose();
|
||||
_M_data(__tmp);
|
||||
_M_capacity(__new_capacity);
|
||||
}
|
||||
|
||||
_M_dispose();
|
||||
_M_data(__tmp);
|
||||
if (__rsize)
|
||||
_S_copy(_M_data(), __rcs._M_data(), __rsize);
|
||||
|
||||
if (__size)
|
||||
_S_copy(_M_data(), __rcs._M_data(), __size);
|
||||
|
||||
if (!_M_is_local())
|
||||
_M_capacity(__size);
|
||||
|
||||
_M_set_length(__size);
|
||||
_M_set_length(__rsize);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user