@@ -1462,6 +1462,11 @@ public:
1462
1462
int compare (size_type __pos1, size_type __n1, const_pointer __s, size_type __n2) const ;
1463
1463
1464
1464
_LIBCPP_INLINE_VISIBILITY bool __invariants () const ;
1465
+
1466
+ _LIBCPP_INLINE_VISIBILITY
1467
+ bool __is_long () const _NOEXCEPT
1468
+ {return bool (__r_.first ().__s .__size_ & __short_mask);}
1469
+
1465
1470
private:
1466
1471
_LIBCPP_INLINE_VISIBILITY
1467
1472
allocator_type& __alloc () _NOEXCEPT
@@ -1470,10 +1475,6 @@ private:
1470
1475
const allocator_type& __alloc () const _NOEXCEPT
1471
1476
{return __r_.second ();}
1472
1477
1473
- _LIBCPP_INLINE_VISIBILITY
1474
- bool __is_long () const _NOEXCEPT
1475
- {return bool (__r_.first ().__s .__size_ & __short_mask);}
1476
-
1477
1478
_LIBCPP_INLINE_VISIBILITY
1478
1479
void __set_short_size (size_type __s) _NOEXCEPT
1479
1480
#if _LIBCPP_BIG_ENDIAN
@@ -3561,9 +3562,29 @@ bool
3561
3562
operator ==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3562
3563
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
3563
3564
{
3564
- return __lhs.size () == __rhs.size () && _Traits::compare (__lhs.data (),
3565
- __rhs.data (),
3566
- __lhs.size ()) == 0 ;
3565
+ size_t __lhs_sz = __lhs.size ();
3566
+ return __lhs_sz == __rhs.size () && _Traits::compare (__lhs.data (),
3567
+ __rhs.data (),
3568
+ __lhs_sz) == 0 ;
3569
+ }
3570
+
3571
+ template <class _Allocator >
3572
+ _LIBCPP_INLINE_VISIBILITY inline
3573
+ bool
3574
+ operator ==(const basic_string<char , char_traits<char >, _Allocator>& __lhs,
3575
+ const basic_string<char , char_traits<char >, _Allocator>& __rhs) _NOEXCEPT
3576
+ {
3577
+ size_t __lhs_sz = __lhs.size ();
3578
+ if (__lhs_sz != __rhs.size ())
3579
+ return false ;
3580
+ const char * __lp = __lhs.data ();
3581
+ const char * __rp = __rhs.data ();
3582
+ if (__lhs.__is_long ())
3583
+ return char_traits<char >::compare (__lp, __rp, __lhs_sz) == 0 ;
3584
+ for (; __lhs_sz != 0 ; --__lhs_sz, ++__lp, ++__rp)
3585
+ if (*__lp != *__rp)
3586
+ return false ;
3587
+ return true ;
3567
3588
}
3568
3589
3569
3590
template <class _CharT , class _Traits , class _Allocator >
0 commit comments