Re: Why is stdin.byLine.writeln so slow?

2014-06-14 Thread via Digitalmars-d-learn
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

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 22:25:25 UTC, H. S. Teoh via Digitalmars-d-learn wrote: In C/C++, you'd have to manually write nested loops to print out the data, which may involve manually calling accessor methods, manually counting them, perhaps storing intermediate output fragments in temporary

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 13, 2014 at 10:02:49PM +, monarch_dodra via Digitalmars-d-learn wrote: [...] > That said, you can use one of D's most powerful formating abilities: > Range formating: > writefln("%-(%s\n%)", stdin.byLine()); > > And BOOM. Does what you want. I freaking love range formatting. > Mor

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
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

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread Ali Çehreli via Digitalmars-d-learn
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 ", " ... "]"

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 21:17:27 UTC, Ali Çehreli wrote: On 06/13/2014 02:08 PM, monarch_dodra wrote: > Given this input: > line 1 > line2 > Yo! > > Then "stdin.byLine.writeln" will produce this string: > ["line 1", "line\t2", "Yo!"] Do you mean writeln() first generates an array and the

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread Jyxent via Digitalmars-d-learn
On Friday, 13 June 2014 at 21:08:08 UTC, monarch_dodra wrote: On Friday, 13 June 2014 at 20:48:16 UTC, Jyxent wrote: I've been playing around with D and noticed that: stdin.byLine.writeln takes ~20 times as long as: foreach(line; stdin.byLine) writeln(line); I asked on IRC and this was sugge

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread Ali Çehreli via Digitalmars-d-learn
On 06/13/2014 02:08 PM, monarch_dodra wrote: > Given this input: > line 1 > line2 > Yo! > > Then "stdin.byLine.writeln" will produce this string: > ["line 1", "line\t2", "Yo!"] Do you mean writeln() first generates an array and then prints that array? I've always imagined that it used the r

Re: Why is stdin.byLine.writeln so slow?

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 20:48:16 UTC, Jyxent wrote: I've been playing around with D and noticed that: stdin.byLine.writeln takes ~20 times as long as: foreach(line; stdin.byLine) writeln(line); I asked on IRC and this was suggested: stdin.byLine(KeepTerminator.yes).copy(stdout.lockingText