bearophile wrote:
Pelle MÃ¥nsson:
foreach (line; open("foobar.txt")) {
writeln(line);
}
With the xio module of my dlibs:
import d.xio: xfile;
foreach (line; xfile("foobar.txt"))
putr(line);
xfile is optimized to reduce memory rellocations as much as possible in the
most common case of about 90 chars long lines.
There is an xstdin too.
Why not just reuse the same buffer as the previous line? That approach
is inherently adaptive. And why is there a need for xstdin vs. xfile?
Stdin _is_ a file.
Andrei