buffered input

Kagamin spam at here.lot
Mon Feb 7 07:54:32 PST 2011


Andrei Alexandrescu Wrote:

> With these primitives a lot of good operating operating on buffered 
> streams can be written efficiently. The range is allowed to reuse data 
> in its buffers (unless that would contradict language invariants, e.g. 
> if T is invariant), so if client code wants to stash away parts of the 
> input, it needs to make a copy.

This surely satisfies most needs for buffered input.

I'm thinking about adaptive caller which can do tricks based on the stream content. Say, strings are usually serialized as |length|data| so the caller can preallocate buffer of exact length and fill it directly.

Will unbuffered file stream bypass system cache?
If yes, you'll have poor performance if the file is already in cache.
If no, you'll have double copy if the caller wants to save the data: from system cache to the range's buffer and from the range's buffer to the caller's buffer.


More information about the Digitalmars-d mailing list