Skip to content

Commit

Permalink
Inline _Memcmp_ranges that is used only once (#4753)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGuteniev authored Jul 5, 2024
1 parent 153b940 commit 557eae3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -5381,15 +5381,6 @@ template <class _Iter1, class _Iter2, class _Pr>
constexpr bool _Equal_memcmp_is_safe =
_Equal_memcmp_is_safe_helper<remove_const_t<_Iter1>, remove_const_t<_Iter2>, remove_const_t<_Pr>>;

template <class _CtgIt1, class _CtgIt2>
_NODISCARD int _Memcmp_ranges(_CtgIt1 _First1, _CtgIt1 _Last1, _CtgIt2 _First2) {
_STL_INTERNAL_STATIC_ASSERT(sizeof(_Iter_value_t<_CtgIt1>) == sizeof(_Iter_value_t<_CtgIt2>));
const auto _First1_ch = reinterpret_cast<const char*>(_STD _To_address(_First1));
const auto _Last1_ch = reinterpret_cast<const char*>(_STD _To_address(_Last1));
const auto _First2_ch = reinterpret_cast<const char*>(_STD _To_address(_First2));
return _CSTD memcmp(_First1_ch, _First2_ch, static_cast<size_t>(_Last1_ch - _First1_ch));
}

template <class _CtgIt1, class _CtgIt2>
_NODISCARD int _Memcmp_count(_CtgIt1 _First1, _CtgIt2 _First2, const size_t _Count) {
_STL_INTERNAL_STATIC_ASSERT(sizeof(_Iter_value_t<_CtgIt1>) == sizeof(_Iter_value_t<_CtgIt2>));
Expand All @@ -5410,7 +5401,11 @@ _NODISCARD _CONSTEXPR20 bool equal(const _InIt1 _First1, const _InIt1 _Last1, co
if (!_STD is_constant_evaluated())
#endif // _HAS_CXX20
{
return _STD _Memcmp_ranges(_UFirst1, _ULast1, _UFirst2) == 0;
_STL_INTERNAL_STATIC_ASSERT(
sizeof(_Iter_value_t<decltype(_UFirst1)>) == sizeof(_Iter_value_t<decltype(_UFirst2)>));
const auto _First1_ch = reinterpret_cast<const char*>(_STD _To_address(_UFirst1));
const auto _Size = reinterpret_cast<const char*>(_STD _To_address(_ULast1)) - _First1_ch;
return _CSTD memcmp(_First1_ch, _STD _To_address(_UFirst2), static_cast<size_t>(_Size)) == 0;
}
}

Expand Down

0 comments on commit 557eae3

Please sign in to comment.