diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-20 01:07:13 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-20 01:07:13 +0000 |
commit | 16baf7c4afd2506ac65ac3e648f454514f8525e9 (patch) | |
tree | fbd3f993eeb346179adea6cacfc33aad6bcf9209 /libstdc++-v3 | |
parent | f99b7896e3c3ce008004c08e79562221799d65d7 (diff) | |
download | gcc-16baf7c4afd2506ac65ac3e648f454514f8525e9.tar.gz |
2005-10-19 Paolo Carlini <pcarlini@suse.de>
* include/ext/sso_string_base.h (_M_swap): Rewrite.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105654 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/sso_string_base.h | 96 |
2 files changed, 56 insertions, 44 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8927bdd194b..902f5f27daf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2005-10-19 Paolo Carlini <pcarlini@suse.de> + * include/ext/sso_string_base.h (_M_swap): Rewrite. + +2005-10-19 Paolo Carlini <pcarlini@suse.de> + * include/ext/rc_string_base.h (_S_terminal): Remove. (_M_set_length): Adjust. (_S_max_size): Change to anonymous enum. diff --git a/libstdc++-v3/include/ext/sso_string_base.h b/libstdc++-v3/include/ext/sso_string_base.h index e578d2448d7..f9b32330f62 100644 --- a/libstdc++-v3/include/ext/sso_string_base.h +++ b/libstdc++-v3/include/ext/sso_string_base.h @@ -248,55 +248,63 @@ namespace __gnu_cxx __sso_string_base<_CharT, _Traits, _Alloc>:: _M_swap(__sso_string_base& __rcs) { - const bool __local = _M_is_local(); - const bool __rcs_local = __rcs._M_is_local(); - - if (__local && __rcs_local) - { - _CharT __tmp_data[_S_local_capacity + 1]; - const size_type __tmp_length = __rcs._M_length(); - _S_copy(__tmp_data, __rcs._M_data(), __rcs._M_length() + 1); - __rcs._M_length(_M_length()); - _S_copy(__rcs._M_data(), _M_data(), _M_length() + 1); - _M_length(__tmp_length); - _S_copy(_M_data(), __tmp_data, __tmp_length + 1); - } - else if (__local && !__rcs_local) - { - const size_type __tmp_capacity = __rcs._M_allocated_capacity; - const size_type __tmp_length = __rcs._M_length(); - _CharT* __tmp_ptr = __rcs._M_data(); - __rcs._M_data(__rcs._M_local_data); - _S_copy(__rcs._M_data(), _M_data(), _M_length() + 1); - __rcs._M_length(_M_length()); - _M_data(__tmp_ptr); - _M_length(__tmp_length); - _M_capacity(__tmp_capacity); - } - else if (!__local && __rcs_local) - { - const size_type __tmp_capacity = _M_allocated_capacity; - const size_type __tmp_length = _M_length(); - _CharT* __tmp_ptr = _M_data(); - _M_data(_M_local_data); - _S_copy(_M_data(), __rcs._M_data(), __rcs._M_length() + 1); - _M_length(__rcs._M_length()); - __rcs._M_data(__tmp_ptr); - __rcs._M_length(__tmp_length); - __rcs._M_capacity(__tmp_capacity); - } + if (_M_is_local()) + if (__rcs._M_is_local()) + { + if (_M_length() && __rcs._M_length()) + { + _CharT __tmp_data[_S_local_capacity + 1]; + traits_type::copy(__tmp_data, __rcs._M_local_data, + __rcs._M_length() + 1); + traits_type::copy(__rcs._M_local_data, _M_local_data, + _M_length() + 1); + traits_type::copy(_M_local_data, __tmp_data, + __rcs._M_length() + 1); + } + else if (__rcs._M_length()) + { + traits_type::copy(_M_local_data, __rcs._M_local_data, + __rcs._M_length() + 1); + traits_type::assign(__rcs._M_local_data[0], _CharT()); + } + else if (_M_length()) + { + traits_type::copy(__rcs._M_local_data, _M_local_data, + _M_length() + 1); + traits_type::assign(_M_local_data[0], _CharT()); + } + } + else + { + const size_type __tmp_capacity = __rcs._M_allocated_capacity; + _S_copy(__rcs._M_local_data, _M_local_data, _M_length() + 1); + _M_data(__rcs._M_data()); + __rcs._M_data(__rcs._M_local_data); + _M_capacity(__tmp_capacity); + } else { const size_type __tmp_capacity = _M_allocated_capacity; - const size_type __tmp_length = _M_length(); - _CharT* __tmp_ptr = _M_data(); - _M_data(__rcs._M_data()); - _M_length(__rcs._M_length()); - _M_capacity(__rcs._M_allocated_capacity); - __rcs._M_data(__tmp_ptr); - __rcs._M_length(__tmp_length); + if (__rcs._M_is_local()) + { + _S_copy(_M_local_data, __rcs._M_local_data, + __rcs._M_length() + 1); + __rcs._M_data(_M_data()); + _M_data(_M_local_data); + } + else + { + _CharT* __tmp_ptr = _M_data(); + _M_data(__rcs._M_data()); + __rcs._M_data(__tmp_ptr); + _M_capacity(__rcs._M_allocated_capacity); + } __rcs._M_capacity(__tmp_capacity); } + + const size_type __tmp_length = _M_length(); + _M_length(__rcs._M_length()); + __rcs._M_length(__tmp_length); } template<typename _CharT, typename _Traits, typename _Alloc> |