3 ms·
It strikes me that the example is a bit contrived: why is howmany decremented unconditionally? The first loop populates out with howmany numbers. The second l
by SloopJon 7y ago
It strikes me that the example is a bit contrived: why is howmany decremented unconditionally? The first loop populates out with howmany numbers. The second loop may set none (other than the ignored value that you point out). I suppose you can use the same trick:
howmany -= (val bitand 1);
But that might complicate the benchmark.
Coincidentally, this was the subject of the first Stack Overflow question Bjarne addressed in an interview the other day:
https://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-processing-an-unsorted-array https://stackoverflow.com/questions/11227809/why-is-processi...