Array!T and find are slow
David Nadlinger via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed May 14 13:29:49 PDT 2014
On Wednesday, 14 May 2014 at 17:36:35 UTC, monarch_dodra wrote:
> Adding a special case "in" Array.Range allows bypassing the
> repeated indexing costs, but at the very least, should be
> implemented "in terms of" find itself, eg:
Shouldn't the extra indirection just vanish into thin air once
opIndex or what have you is inlined? I don't see a conceptual
reason for overhead in this case.
Of course, the compiler probably wouldn't be able to infer any of
the memchr/… optimizations find does for the array case, but
Damian's alternative version doesn't do any of that either.
David
More information about the Digitalmars-d-learn
mailing list