For a hot loop in an arithmetic tool I need to make the trade-off between keeping the index of the lowest bit of a struct's element in memory, or looking it up when necessary. Keeping it in memory works but is clunky. Dropping the field is limited by how fast I can do this instead;
inline bool operator< (const unsigned long& lhs, const unsigned long& rhs) {
unsigned long left, right;
_BitScanForward(&left , lhs);
_BitScanForward(&right, rhs);
return left < right;
}
(Simplified). So 2 < 4
, but 2 == 6
. I'm wondering if there's an easier way of extracting this info.