Commit fe4dbb77 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

avoid implicit conversions in Bits

Differential Revision: D34056336

fbshipit-source-id: adf4c0b96d6fd3f5e15c7bfefe7e908e85baf5b1
parent c1b3be25
...@@ -200,14 +200,17 @@ struct Bits { ...@@ -200,14 +200,17 @@ struct Bits {
template <class T, class Traits> template <class T, class Traits>
inline void Bits<T, Traits>::set(T* p, size_t bit) { inline void Bits<T, Traits>::set(T* p, size_t bit) {
auto mask = static_cast<UnderlyingType>(one << bitOffset(bit));
T& block = p[blockIndex(bit)]; T& block = p[blockIndex(bit)];
Traits::store(block, Traits::loadRMW(block) | (one << bitOffset(bit))); Traits::store(block, Traits::loadRMW(block) | mask);
} }
template <class T, class Traits> template <class T, class Traits>
inline void Bits<T, Traits>::clear(T* p, size_t bit) { inline void Bits<T, Traits>::clear(T* p, size_t bit) {
auto mask = static_cast<UnderlyingType>(one << bitOffset(bit));
auto ksam = static_cast<UnderlyingType>(~mask);
T& block = p[blockIndex(bit)]; T& block = p[blockIndex(bit)];
Traits::store(block, Traits::loadRMW(block) & ~(one << bitOffset(bit))); Traits::store(block, Traits::loadRMW(block) & ksam);
} }
template <class T, class Traits> template <class T, class Traits>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment