Array!T and find are slow

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 14 15:26:21 PDT 2014


On Wed, 14 May 2014 21:20:05 +0000
Kapps via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com> wrote:

> That pull shows that the previous behaviour was to use enforce?
> Isn't this very expensive, particularly considering that enforce
> uses lazy non-scope arguments?

Yeah, much as Andrei would hate to hear it (enforce was his idea, and he quite
likes the idiom), the fact that lazy is so inefficient makes it so that it's
arguably bad practice to use it in high performance code. We really need to
find a way to make it so that lazy is optimized properly so that we _can_
safely use enforce, but for now, it's not a good idea unless the code that
you're working on can afford the performance hit.

Honestly, in general, I'd avoid most anything which uses lazy (e.g. that's why
I'd use explict try-catch blocks rather than use
std.exception.assumeWontThrow - like enforce, it's a nice idea, but it's too
expensive at this point).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list