mirror of git://gcc.gnu.org/git/gcc.git
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
This commit is contained in:
parent
5bfe5df3d8
commit
37a68925ce
|
@ -1,3 +1,10 @@
|
||||||
|
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>
|
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/char/4.cc: New.
|
||||||
|
|
|
@ -2380,7 +2380,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
inline basic_string<_CharT, _Traits, _Alloc>
|
inline basic_string<_CharT, _Traits, _Alloc>
|
||||||
operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
|
operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
|
||||||
basic_string<_CharT, _Traits, _Alloc>&& __rhs)
|
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>
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
||||||
inline basic_string<_CharT, _Traits, _Alloc>
|
inline basic_string<_CharT, _Traits, _Alloc>
|
||||||
|
@ -2390,8 +2396,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc>
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
||||||
inline basic_string<_CharT, _Traits, _Alloc>
|
inline basic_string<_CharT, _Traits, _Alloc>
|
||||||
operator+(_CharT __lhs, basic_string<_CharT,
|
operator+(_CharT __lhs,
|
||||||
_Traits, _Alloc>&& __rhs)
|
basic_string<_CharT, _Traits, _Alloc>&& __rhs)
|
||||||
{ return std::move(__rhs.insert(0, 1, __lhs)); }
|
{ return std::move(__rhs.insert(0, 1, __lhs)); }
|
||||||
|
|
||||||
template<typename _CharT, typename _Traits, typename _Alloc>
|
template<typename _CharT, typename _Traits, typename _Alloc>
|
||||||
|
|
|
@ -2118,7 +2118,13 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
|
||||||
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
|
inline __versa_string<_CharT, _Traits, _Alloc, _Base>
|
||||||
operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
|
operator+(__versa_string<_CharT, _Traits, _Alloc, _Base>&& __lhs,
|
||||||
__versa_string<_CharT, _Traits, _Alloc, _Base>&& __rhs)
|
__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 _CharT, typename _Traits, typename _Alloc,
|
||||||
template <typename, typename, typename> class _Base>
|
template <typename, typename, typename> class _Base>
|
||||||
|
|
Loading…
Reference in New Issue