Skip to content
Snippets Groups Projects
Unverified Commit e1729eb8 authored by Jonathan Wakely's avatar Jonathan Wakely Committed by Jonathan Wakely
Browse files

libstdc++: Use memcmp to optimize std::bitset::_M_is_equal() [PR113807]

As noted in the PR the compiler doesn't seem able to do this on its own,
so we get better code at all optimization levels by using memcmp.

libstdc++-v3/ChangeLog:

	PR libstdc++/113807
	* include/std/bitset (bitset::_M_is_equal()): Use memcmp to
	optimize operator==.
parent 0ba18853
No related branches found
No related tags found
No related merge requests found
......@@ -205,10 +205,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_GLIBCXX14_CONSTEXPR bool
_M_is_equal(const _Base_bitset<_Nw>& __x) const _GLIBCXX_NOEXCEPT
{
for (size_t __i = 0; __i < _Nw; ++__i)
if (_M_w[__i] != __x._M_w[__i])
return false;
return true;
#if __cplusplus >= 201402L
if (__builtin_is_constant_evaluated())
{
for (size_t __i = 0; __i < _Nw; ++__i)
if (_M_w[__i] != __x._M_w[__i])
return false;
return true;
}
#endif
return !__builtin_memcmp(_M_w, __x._M_w, _Nw * sizeof(_WordT));
}
template<size_t _Nb>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment