Skip to content

Commit

Permalink
Enable narrowing conversion warning in remap_index, should index type…
Browse files Browse the repository at this point in the history
… change.
  • Loading branch information
Maxim Egorushkin committed Apr 30, 2023
1 parent 5e902b3 commit 996a85c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions include/atomic_queue/atomic_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,11 @@ struct GetIndexShuffleBits<false, array_size, elements_per_cache_line> {
// minimizes contention. This is done by swapping the lowest order N bits (which are the index of
// the element within the cache line) with the next N bits (which are the index of the cache line)
// of the element index.
template<int BITS>
constexpr unsigned remap_index_with_mix(unsigned index, unsigned mix) {
return index ^ mix ^ (mix << BITS);
}

template<int BITS>
constexpr unsigned remap_index(unsigned index) noexcept {
return remap_index_with_mix<BITS>(index, (index ^ (index >> BITS)) & ((1u << BITS) - 1));
unsigned constexpr mix_mask{(1u << BITS) - 1};
unsigned const mix{(index ^ (index >> BITS)) & mix_mask};
return index ^ mix ^ (mix << BITS);
}

template<>
Expand Down

0 comments on commit 996a85c

Please sign in to comment.