howto count lines - fast

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 31 15:46:17 PDT 2017


On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn 
wrote:
> I did some digging around, and it seems that wc is using glibc's memchr,
> which is highly-optimized, whereas std.algorithm.count just uses a
> simplistic loop. Which is strange, because I'm pretty sure somebody
> optimized std.algorithm some time ago to use memchr() instead of a loop
> when searching for a byte value in an array.  Whatever happened to
> that??

I don't know, but memchr wouldn't work with CTFE, so someone might have
removed it to make it work in CTFE (though that could be done with a
different branch for CTFE). Or maybe it never made it into std.algorithm for
one reason or another.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list