3 ms·
They don't have to be stored as a usize. This is slightly annoying because it may add casts, but not if one already has a newtype wrapper around the integers: t
by dbaupp 8y ago
They don't have to be stored as a usize. This is slightly annoying because it may add casts, but not if one already has a newtype wrapper around the integers: the type stored in the wrapper could be a u32, with the conversions to usize hidden by the indexing APIs.
- cjhanks 8y ago2 cycles or so, I think. In my experience, this cost is usually overwhelmed by the inherent (to this class of algorithms) cache misses.
- dbaupp 8y ago2 cycles for a 32-bit to 64-bit extension? I don't think that makes sense: for instance, on x86-64, there's no cast necessary, just use the %rax register instead of the %eax one (plus, memory addressing works fine with 32 bit registers directly). I believe the same is true of AArch64 (64-bit ARM) with the 32-bit register W0 being the bottom half of the 64-bit register X0.
- cjhanks 8y agoYeah, your intuition seems correct to me. I wonder if I was thinking about 64 to 32 signed, or if just didn't know.