lastCount_(lastCount) {
}
explicit Adaptor(size_t n, const value_type& value = value_type())
- : c_(Node::nodeCount(n), fullNode(value)),
- lastCount_(n % Node::kElementCount ?: Node::kElementCount) {
+ : c_(Node::nodeCount(n), fullNode(value)) {
+ const auto count = n % Node::kElementCount;
+ lastCount_ = count != 0 ? count : Node::kElementCount;
}
Adaptor(const Adaptor&) = default;
reinterpret_cast<folly::Unaligned<uint64_t>*>(block), inner);
if (skipQuantum != 0) {
- size_t nextSkipPointerSize = value / (skipQuantum ?: 1);
+ size_t nextSkipPointerSize = value / skipQuantum;
while (skipPointersSize_ < nextSkipPointerSize) {
auto pos = skipPointersSize_++;
folly::storeUnaligned<SkipValueType>(
}
if (forwardQuantum != 0) {
- if (size_ != 0 && (size_ % (forwardQuantum ?: 1) == 0)) {
- const auto pos = size_ / (forwardQuantum ?: 1) - 1;
+ if (size_ != 0 && (size_ % forwardQuantum == 0)) {
+ const auto pos = size_ / forwardQuantum - 1;
folly::storeUnaligned<SkipValueType>(
forwardPointers_ + pos * sizeof(SkipValueType), value);
}
layout.bits = bitVectorSizeInBytes;
if (skipQuantum != 0) {
- size_t numSkipPointers = upperBound / (skipQuantum ?: 1);
+ size_t numSkipPointers = upperBound / skipQuantum;
layout.skipPointers = numSkipPointers * sizeof(SkipValueType);
}
if (forwardQuantum != 0) {
- size_t numForwardPointers = size / (forwardQuantum ?: 1);
+ size_t numForwardPointers = size / forwardQuantum;
layout.forwardPointers = numForwardPointers * sizeof(SkipValueType);
}
// Use forward pointer.
if (Encoder::forwardQuantum > 0 && n > Encoder::forwardQuantum) {
- // Workaround to avoid 'division by zero' compile-time error.
- constexpr size_t q = Encoder::forwardQuantum ?: 1;
-
- const size_t steps = position_ / q;
+ const size_t steps = position_ / Encoder::forwardQuantum;
const size_t dest = folly::loadUnaligned<SkipValueType>(
forwardPointers_ + (steps - 1) * sizeof(SkipValueType));
reposition(dest);
- n = position_ + 1 - steps * q;
+ n = position_ + 1 - steps * Encoder::forwardQuantum;
// Correct inner_ will be set at the end.
}
// more serialization-friendly way (upperSizeBits doesn't need
// to be known by this function, unlike upper).
- // '?: 1' is a workaround for false 'division by zero'
- // compile-time error.
- size_t numSkipPointers = (8 * upper - size) / (skipQuantum ?: 1);
+ size_t numSkipPointers = (8 * upper - size) / skipQuantum;
layout.skipPointers = numSkipPointers * sizeof(SkipValueType);
}
// Store (1-indexed) position of every forwardQuantum-th
// 1-bit in upper bits sequence.
/* static */ if (forwardQuantum != 0) {
- size_t numForwardPointers = size / (forwardQuantum ?: 1);
+ size_t numForwardPointers = size / forwardQuantum;
layout.forwardPointers = numForwardPointers * sizeof(SkipValueType);
}
// Use forward pointer.
if (Encoder::forwardQuantum > 0 && n > Encoder::forwardQuantum) {
- // Workaround to avoid 'division by zero' compile-time error.
- constexpr size_t q = Encoder::forwardQuantum ?: 1;
-
- const size_t steps = position_ / q;
+ const size_t steps = position_ / Encoder::forwardQuantum;
const size_t dest =
folly::loadUnaligned<SkipValueType>(
forwardPointers_ + (steps - 1) * sizeof(SkipValueType));
- reposition(dest + steps * q);
- n = position_ + 1 - steps * q; // n is > 0.
+ reposition(dest + steps * Encoder::forwardQuantum);
+ n = position_ + 1 - steps * Encoder::forwardQuantum; // n is > 0.
// Correct inner_ will be set at the end.
}
// Use skip pointer.
if (Encoder::skipQuantum > 0 && v >= value_ + Encoder::skipQuantum) {
- // Workaround to avoid 'division by zero' compile-time error.
- constexpr size_t q = Encoder::skipQuantum ?: 1;
-
- const size_t steps = v / q;
+ const size_t steps = v / Encoder::skipQuantum;
const size_t dest =
folly::loadUnaligned<SkipValueType>(
skipPointers_ + (steps - 1) * sizeof(SkipValueType));
- reposition(dest + q * steps);
+ reposition(dest + Encoder::skipQuantum * steps);
position_ = dest - 1;
// Correct inner_ and value_ will be set during the next()
Generator(Source source, Ops ops, size_t threads)
: source_(std::move(source)),
ops_(std::move(ops)),
- threads_(threads
- ?: std::max<size_t>(1, sysconf(_SC_NPROCESSORS_CONF))) {}
+ threads_(
+ threads ? threads
+ : std::max<size_t>(1, sysconf(_SC_NPROCESSORS_CONF))) {}
template <class Handler>
bool apply(Handler&& handler) const {
Generator(Source source, const Predicate& pred, size_t nThreads)
: source_(std::move(source)),
pred_(pred),
- nThreads_(nThreads ?: sysconf(_SC_NPROCESSORS_ONLN)) {
+ nThreads_(nThreads ? nThreads : sysconf(_SC_NPROCESSORS_ONLN)) {
}
template<class Body>