On Monday, 4 May 2015 at 23:20:57 UTC, Alex Parrill wrote:
On Monday, 4 May 2015 at 19:23:08 UTC, Freddy wrote:
On Monday, 4 May 2015 at 15:16:25 UTC, Alex Parrill wrote:
The ploblem is that all the functions in
std.range,std.algorithm and many other wrappers would ignore
byChucks and produce much slower code.
How so? `file.byChunks(4096).joiner` is a range that acts as if
you read each byte out of the file one at a time, but actually
reads them in 4096-byte buffers. It's still compatible with all
of the range and algorithm functions.
Reading an arbitrary number of data after being wrapped.
For example
----
void func(R)(R range){//expects range of strings
string[] elms=range.read(5);
string[] elms2=range.read(9);
/++..++/
}
void caller(){
auto file=...;//unbuffered file
file.map!(a=>a.to!string).func();
}
----
Using byChucks would cause much more reallocation.