AA code 50x slower
evilrat
evilrat666 at gmail.com
Mon Feb 17 04:15:36 UTC 2020
On Monday, 17 February 2020 at 02:18:15 UTC, AlphaPurned wrote:
>
> But the input to the AA is static, it never changes. I thought
> D would essentially treat it as a constant and compute it once?
>
> (I'm only using the AA in one place but it is in another
> template that is used twice. I can't imagine it would couldn't
> figure out how to optimzie it, I'm feeding it a constant so...)
The reason is that AA is a runtime-dependent construct, but it's
not available at compile time, nor that there is some known ahead
of time interface to it(ok, not exactly but something like that),
so instead it does this whenever AA enum is referenced.
See Steven's code above, it might work like you thought however
despite whatever input it will likely have exactly one variant of
it because instantiated on string[] type, if that's the case and
this is not what you wanted you might try tuple parameter instead
of string[].
More information about the Digitalmars-d-learn
mailing list