Reads by line in an efficient way (10 times faster than File.byLine
from std.stdio).
This is accomplished by reading entire buffers (fgetc() is not used),
and allocating as little as possible.
The char \n is considered as separator, removing the previous \r
if it exists.
The \n is never returned. The \r is not returned if it was
part of a \r\n (but it is returned if it was by itself).
The returned string is always a substring of a temporary
buffer, that must not be stored. If necessary, you must
use str[] or .dup or .idup to copy to another string.
File f = File("file.txt");
foreach (string line; f.byLineFast) {
...process line...
//Make a copy:
string copy = line[];
}
The file isn't closed when done iterating, unless it was
the only reference to the file (same as std.stdio.byLine).
(example: ByLineFast(File("file.txt"))).
Reads by line in an efficient way (10 times faster than File.byLine from std.stdio). This is accomplished by reading entire buffers (fgetc() is not used), and allocating as little as possible.
The char \n is considered as separator, removing the previous \r if it exists.
The \n is never returned. The \r is not returned if it was part of a \r\n (but it is returned if it was by itself).
The returned string is always a substring of a temporary buffer, that must not be stored. If necessary, you must use str[] or .dup or .idup to copy to another string.