@@ -1549,6 +1549,11 @@ private:
1549
1549
inline
1550
1550
void __init (size_type __n, value_type __c);
1551
1551
1552
+ // Identical to __init(s, sz), except that this function is always
1553
+ // externally instantiated and not inlined: this function is the
1554
+ // slow path for the (inlined) copy constructor.
1555
+ void __init_long_external (const value_type* __s, size_type __sz);
1556
+
1552
1557
template <class _InputIterator >
1553
1558
inline
1554
1559
_EnableIf
@@ -1797,6 +1802,18 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty
1797
1802
traits_type::assign (__p[__sz], value_type ());
1798
1803
}
1799
1804
1805
+ template <class _CharT , class _Traits , class _Allocator >
1806
+ void basic_string<_CharT, _Traits, _Allocator>::__init_long_external(
1807
+ const _CharT* __s, size_type __sz) {
1808
+ size_type __cap = __recommend (__sz);
1809
+ pointer __p = __alloc_traits::allocate (__alloc (), __cap + 1 );
1810
+ __set_long_pointer (__p);
1811
+ __set_long_cap (__cap + 1 );
1812
+ __set_long_size (__sz);
1813
+ traits_type::copy (_VSTD::__to_address (__p), __s, __sz);
1814
+ traits_type::assign (__p[__sz], value_type ());
1815
+ }
1816
+
1800
1817
template <class _CharT , class _Traits , class _Allocator >
1801
1818
template <class >
1802
1819
basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
@@ -1840,7 +1857,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st
1840
1857
if (!__str.__is_long ())
1841
1858
__r_.first ().__r = __str.__r_ .first ().__r ;
1842
1859
else
1843
- __init (_VSTD::__to_address (__str.__get_long_pointer ()), __str.__get_long_size ());
1860
+ __init_long_external (_VSTD::__to_address (__str.__get_long_pointer ()), __str.__get_long_size ());
1844
1861
#if _LIBCPP_DEBUG_LEVEL >= 2
1845
1862
__get_db ()->__insert_c (this );
1846
1863
#endif
@@ -1854,7 +1871,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(
1854
1871
if (!__str.__is_long ())
1855
1872
__r_.first ().__r = __str.__r_ .first ().__r ;
1856
1873
else
1857
- __init (_VSTD::__to_address (__str.__get_long_pointer ()), __str.__get_long_size ());
1874
+ __init_long_external (_VSTD::__to_address (__str.__get_long_pointer ()), __str.__get_long_size ());
1858
1875
#if _LIBCPP_DEBUG_LEVEL >= 2
1859
1876
__get_db ()->__insert_c (this );
1860
1877
#endif
0 commit comments