[libcxx-commits] [libcxx] fa40b41 - Revert "[libc++] Optimize / partially inline basic_string copy constructor"

Eric Fiselier via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 20 18:42:42 PST 2020


Author: Eric Fiselier
Date: 2020-01-20T21:41:58-05:00
New Revision: fa40b41168f68cb53cb1a7bb3dcb71ac3010e9d4

URL: https://github.com/llvm/llvm-project/commit/fa40b41168f68cb53cb1a7bb3dcb71ac3010e9d4
DIFF: https://github.com/llvm/llvm-project/commit/fa40b41168f68cb53cb1a7bb3dcb71ac3010e9d4.diff

LOG: Revert "[libc++] Optimize / partially inline basic_string copy constructor"

This reverts commit a8a9c8e0a11abc9ed4ed78fed528334371fedf87.

There are multiple reported failures caused by this change.
Each failure is really weird, but it makes sense to revert
while investigating.

Added: 
    

Modified: 
    libcxx/include/string

Removed: 
    


################################################################################
diff  --git a/libcxx/include/string b/libcxx/include/string
index b9a402d58928..313ef9f67900 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1549,11 +1549,6 @@ private:
     inline
     void __init(size_type __n, value_type __c);
 
-    // Identical to __init(s, sz), except that this function is always
-    // externally instantiated and not inlined: this function is the
-    // slow path for the (inlined) copy constructor.
-    void __init_long_external(const value_type* __s, size_type __sz);
-
     template <class _InputIterator>
     inline
     _EnableIf
@@ -1802,18 +1797,6 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
     traits_type::assign(__p[__sz], value_type());
 }
 
-template <class _CharT, class _Traits, class _Allocator>
-void basic_string<_CharT, _Traits, _Allocator>::__init_long_external(
-    const _CharT* __s, size_type __sz) {
-  size_type __cap = __recommend(__sz);
-  pointer __p = __alloc_traits::allocate(__alloc(), __cap + 1);
-  __set_long_pointer(__p);
-  __set_long_cap(__cap + 1);
-  __set_long_size(__sz);
-  traits_type::copy(_VSTD::__to_address(__p), __s, __sz);
-  traits_type::assign(__p[__sz], value_type());
-}
-
 template <class _CharT, class _Traits, class _Allocator>
 template <class>
 basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
@@ -1857,7 +1840,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
     if (!__str.__is_long())
         __r_.first().__r = __str.__r_.first().__r;
     else
-        __init_long_external(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
+        __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
 #if _LIBCPP_DEBUG_LEVEL >= 2
     __get_db()->__insert_c(this);
 #endif
@@ -1871,7 +1854,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
     if (!__str.__is_long())
         __r_.first().__r = __str.__r_.first().__r;
     else
-        __init_long_external(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
+        __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
 #if _LIBCPP_DEBUG_LEVEL >= 2
     __get_db()->__insert_c(this);
 #endif


        


More information about the libcxx-commits mailing list