summaryrefslogtreecommitdiffstats
path: root/libcxx/include
diff options
context:
space:
mode:
authormarshall <mclow.lists@gmail.com>2019-11-27 07:13:00 -0800
committermarshall <mclow.lists@gmail.com>2019-11-27 07:13:32 -0800
commit703c26f03be74daf6e483380e6b23029a3851081 (patch)
tree74a4b0cf708652a469975a1f470d401af29111d9 /libcxx/include
parentf59614d906b5428f3687a44ee018df5840b301dd (diff)
downloadbcm5719-llvm-703c26f03be74daf6e483380e6b23029a3851081.tar.gz
bcm5719-llvm-703c26f03be74daf6e483380e6b23029a3851081.zip
Optimize and fix basic_string move assignment operator. Reviewed as https://reviews.llvm.org/D68623. Thanks to mvels for the patch.
Diffstat (limited to 'libcxx/include')
-rw-r--r--libcxx/include/string18
1 files changed, 14 insertions, 4 deletions
diff --git a/libcxx/include/string b/libcxx/include/string
index c16dbedc51c..4e0b21135a7 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -2289,10 +2289,20 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
_NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
#endif
{
- __clear_and_shrink();
- __r_.first() = __str.__r_.first();
- __move_assign_alloc(__str);
- __str.__zero();
+ if (__is_long()) {
+ __alloc_traits::deallocate(__alloc(), __get_long_pointer(),
+ __get_long_cap());
+#if _LIBCPP_STD_VER <= 14
+ if (!is_nothrow_move_assignable<allocator_type>::value) {
+ __set_short_size(0);
+ traits_type::assign(__get_short_pointer()[0], value_type());
+ }
+#endif
+ }
+ __move_assign_alloc(__str);
+ __r_.first() = __str.__r_.first();
+ __str.__set_short_size(0);
+ traits_type::assign(__str.__get_short_pointer()[0], value_type());
}
template <class _CharT, class _Traits, class _Allocator>
OpenPOWER on IntegriCloud