Making byLine faster: we should be able to delegate this

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 23 14:29:47 PDT 2015


On 3/23/15 2:13 PM, rumbu wrote:
>
> Since this code is clearly not the best for this task, as I suspected, I
> looked into jitted code and it seems that the .net runtime is smart
> enough to recognize this pattern and is doing the following:
> - file is mapped into memory using CreateFileMapping
> - does not perform any decoding, since \r and \n are ASCII
> - does not create any list
> - searches incrementally for \r, \r\n, \n using CompareStringA and
> LOCALE_INVARIANT and increments at each end of line
> - there is no temporary memory allocation since searching is performed
> directly on the mapping handle
> - returns the count.

This is great investigative and measuring work. Thanks! -- Andrei



More information about the Digitalmars-d mailing list