Commit 37a68925 by Paolo Carlini Committed by Paolo Carlini

basic_string.h (operator+(basic_string<>&&, basic_string<>&&)): Optimize better.

2010-12-19  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/basic_string.h (operator+(basic_string<>&&,
	basic_string<>&&)): Optimize better.
	* include/ext/vstring.h (operator+(__versa_string<>&&,
	__versa_string<>&)): Likewise.

From-SVN: r168061
parent 5bfe5df3
2010-12-19 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (operator+(basic_string<>&&,
basic_string<>&&)): Optimize better.
* include/ext/vstring.h (operator+(__versa_string<>&&,
__versa_string<>&)): Likewise.
2010-12-19 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/21_strings/basic_string/operators/char/4.cc: New.
* testsuite/21_strings/basic_string/operators/wchar_t/4.cc: Likewise.
* testsuite/ext/vstring/operators/2.cc: Likewise.
......
......@@ -2380,7 +2380,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
inline basic_string<_CharT, _Traits, _Alloc>
operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
basic_string<_CharT, _Traits, _Alloc>&& __rhs)
{ return std::move(__lhs.append(__rhs)); }
{
const auto __size = __lhs.size() + __rhs.size();
const bool __cond = (__size > __lhs.capacity()
&& __size <= __rhs.capacity());
return __cond ? std::move(__rhs.insert(0, __lhs))
: std::move(__lhs.append(__rhs));
}
template<typename _CharT, typename _Traits, typename _Alloc>
inline basic_string<_CharT, _Traits, _Alloc>
......@@ -2390,8 +2396,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
template<typename _CharT, typename _Traits, typename _Alloc>
inline basic_string<_CharT, _Traits, _Alloc>
operator+(_CharT __lhs, basic_string<_CharT,
_Traits, _Alloc>&& __rhs)
operator+(_CharT __lhs,
basic_string<_CharT, _Traits, _Alloc>&& __rhs)
{ return std::move(__rhs.insert(0, 1, __lhs)); }
template<typename _CharT, typename _Traits, typename _Alloc>
......
......@@ -2118,7 +2118,13 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
__versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
{ return std::move(__lhs.append(__rhs)); }
{
const auto __size = __lhs.size() + __rhs.size();
const bool __cond = (__size > __lhs.capacity()
&& __size <= __rhs.capacity());
return __cond ? std::move(__rhs.insert(0, __lhs))
: std::move(__lhs.append(__rhs));
}
template<typename _CharT, typename _Traits, typename _Alloc,
template <typename, typename, typename> class _Base>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment