0 is not a power of 2
Martin Nowak via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 19 02:35:24 PDT 2015
On Tuesday, 19 May 2015 at 07:56:27 UTC, Atila Neves wrote:
> Aren't predictable branches cheap on current architectures?
Yes they are, and it seems one would rarely if ever call isPowOf2
with 0 in std.allocator. A good thing to do, is to use a good
hardware event profiler like perf, and record the branch misses.
Perf is also the right tool to compare the branchless version (I
doubt it's significantly better, especially since the felt of the
0 branch is just a constant).
More information about the Digitalmars-d
mailing list