Speed of horizontal flip
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Apr 2 04:08:44 PDT 2015
On Thursday, 2 April 2015 at 05:21:08 UTC, thedeemon wrote:
> std.algorithm.reverse uses ranges, and shamefully DMD is really
> bad at optimizing away range-induced costs.
The specialisation of reverse selected for slices does not use
the range interface, it's all just indexing. The only overheads
come from:
a) function calls, if the inliner isn't doing its job (which it
really should be in these cases).
b) a check for aliasing in swapAt, which is only done for ranges
of static arrays. Again, should be optimised away in this case,
but it's possible DMD doesn't manage it. Either way, it's a
trivially predictable branch and should be effectively free at
the CPU level.
Once you've got past those, it's just straight loop I posted
before.
More information about the Digitalmars-d-learn
mailing list