Why is stdin.byLine.writeln so slow?
via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 14 03:41:21 PDT 2014
On Friday, 13 June 2014 at 22:12:01 UTC, Ali Çehreli wrote:
> On 06/13/2014 03:02 PM, monarch_dodra wrote:
>
> > No, it just receives a range, so it does range formating. eg:
> > "[" ~ Element ~ ", " ~ Element ... "]".
>
> It still looks like it could send the formatting characters as
> well as the elements separately to the output stream:
>
> "["
> Element
> ", "
> ...
> "]"
>
> I am assuming that the slowness in OP's example is due to
> constructing a long string.
It already does what you suggest, and doesn't constructing one
big string. You can test this
void main() {
import std.stdio;
stdin.byLine.writeln;
}
When you type in several lines in the terminal, it will output
the first element as soon as you pressed enter for the first line.
More information about the Digitalmars-d-learn
mailing list