[phobos] UnbufferedFile, or, abstracting the File ranges
Andrei Alexandrescu
andrei at erdani.com
Tue May 11 08:14:55 PDT 2010
Steve Schveighoffer wrote:
> Re: byLine and byChunk, I don't think these are a good idea on
> unbuffered files.
byLine is onerous because it reads one character at a time, but byChunk
makes a lot of sense. It essentially is buffering straight in user's
buffers. A lot of Unix utilities do that.
> For example, your current implementation will be extremely slow.
> Reading one char at a time is OK on a buffered file, because most times
> its just a simple fetch of a char from a buffer. But your
> implementation reads a single character at a time from the actual file
> on disk, a very slow operation.
>
> I think unbuffered files are good for when you want to handle the
> buffering yourself, or when you want to pass them to child processes.
Actually a great use case is character-level unbuffered files when you
want to do something for each keypress off a tty.
Andrei
More information about the phobos
mailing list