Skip to content

Commit fc7c189

Browse files
committed
Simplify flip() for std::bit_set
1 parent c1e7e45 commit fc7c189

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

libcxx/include/bitset

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -319,18 +319,8 @@ __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {
319319

320320
template <size_t _N_words, size_t _Size>
321321
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Size>::flip() _NOEXCEPT {
322-
// do middle whole words
323-
size_type __n = _Size;
324-
__storage_pointer __p = __first_;
325-
for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
326-
*__p = ~*__p;
327-
// do last partial word
328-
if (__n > 0) {
329-
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
330-
__storage_type __b = *__p & __m;
331-
*__p &= ~__m;
332-
*__p |= ~__b & __m;
333-
}
322+
for (size_type __i = 0; __i < _N_words; ++__i)
323+
__first_[__i] = ~__first_[__i];
334324
}
335325

336326
template <size_t _N_words, size_t _Size>

0 commit comments

Comments
 (0)