> It seems to me that the C++ Standards Committee is doing a decent job maintaining the language, and introducing useful features when it makes sense to do so. This can’t be further from truth. C++ is essentially Frankenstein’s monster.
I believe one of the main goals of whatever shadowy organizations are behind the "standards committee" is to sabotage the language to help clear the way for Rust. If these people really have a great idea for what the future C++ should be like, then they should introduce that language all at once. Let us see their grand vision in one big package that can be embraced or rejected. This steady drip-drip-drip of half-bake…
It's so that
if (max)
is truthy iff max has been assigned (including the case where it's been assigned zero).I don't know if it's possible for max to be assigned zero in this specific context, or what the correct behavior is if max==0. However, the good thing about this code is that it clearly communicates that the intended check is 'has been assigned to' rather than 'is nonzero'.
The function, for reference:
void WasmShuffleAnalyzer::TryReduceFromMSB(OpIndex input,
const Simd128ShuffleOp& shuffle,
uint8_t lower_limit,
uint8_t upper_limit) {
DemandedBytes demanded = GetDemandedBytes(&shuffle);
std::optional max = {};
for (unsigned i = 0; i = lower_limit && index (index % kSimd128Size),
max.value_or(uint8_t{0}));
}
}
if (max) {
// input can be reduced.
TRACE("Can reduce Op %d based upon max used index: %d\n", input.id(),
max.value());
demanded_byte_analysis_.Add(
input, DemandedBytes::LowFromMaxShuffleIndex(max.value()));
}
}