07-Feb-2014 12:24, Walter Bright пишет:
https://github.com/D-Programming-Language/phobos/pull/1911

This adds a package std.buffer, and the first entry in that package,
std.buffer.scopebuffer.

ScopeBuffer is an OutputRange that sits on the stack, and overflows to
malloc/free. It's designed to help in eliminating gc allocation by lower
level functions that return buffers, such as std.path.buildPath(). With
some judicious user tuning of the initial stack size, it can virtually
eliminate storage allocation.

Using it is @system, but the user of ScopeBuffer can be @trusted.

An output range like this is a precursor to eliminating the excessive gc
use by functions such as buildPath().

Some food for thought:

1. I guess there is a distinctive quality to a buffer (i.e. it's not just any output range). The current interface looks quite arbitrary - is 'pop' required for any buffer? A trait like isBuffer is in order, to allow user code to target any buffers including non-Phobos ones.

2. May need buffer.package.d to import all common buffers (there is only one now, but with time...).


--
Dmitry Olshansky

Reply via email to