Good project: stride() with constant stride value
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Fri Mar 4 09:49:09 PST 2016
On Friday, 4 March 2016 at 16:45:42 UTC, Andrei Alexandrescu
wrote:
> Currently we have a very useful stride() function that allows
> spanning a random access range with a specified step, e.g. 0,
> 3, 6, 9, ... for step 3.
>
> I've run some measurements recently and it turns out a
> compile-time-known stride is a lot faster than a variable. So I
> was thinking to improve Stride(R) to take an additional
> parameter: Stride(R, size_t step = 0). If step is 0, then use a
> runtime-valued stride as until now. If nonzero, Stride should
> use that compile-time step.
>
> Takers?
>
>
> Andrei
Surely after inlining (I mean real inlining, not dmd) it makes no
difference, a constant is a constant?
I remember doing tests of things like that and finding that not
only did it not make a difference to performance, ldc produced
near-identical asm either way.
More information about the Digitalmars-d
mailing list