Array!T and find are slow

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 14 22:53:45 PDT 2014


On Thursday, 15 May 2014 at 04:37:16 UTC, Jonathan M Davis via 
Digitalmars-d-learn wrote:
> enforce(cond, "failure");
>
> really should just translate to something close to
>
> if(!cond) throw new Exception("failure");
>
> but it doesn't do anything close to that. And as long as it 
> doesn't, enforce
> is of questionable value in any code that cares about 
> efficiency.
>
> - Jonathan M Davis

As a workaround, I'm sure we could specialize enforce without 
lazy for built-in types?

BTW: Why *is* enforce lazy again? I don't really see it. I makes 
more sense for things like "collectException" I guess, but I 
don't see it for enforce.


More information about the Digitalmars-d-learn mailing list