Difference between revisions of "Std.buffer.scopebuffer"

From D Wiki
Jump to: navigation, search
(Add ddoc link)
m
 
Line 17: Line 17:
 
== Current state ==
 
== Current state ==
  
After preliminary discussion proposal is about to enter formal review process.
+
Under review
  
 
== Initial discussion ==
 
== Initial discussion ==
Line 43: Line 43:
 
* Some style differences from majority of "modern" Phobos
 
* Some style differences from majority of "modern" Phobos
 
* Relation with postblit-enabled types
 
* Relation with postblit-enabled types
 +
 +
== Review 1 ==
 +
 +
=== Related Links ===
 +
 +
[http://forum.dlang.org/post/ozeprbbmwwxurzgtdjva@forum.dlang.org Review thread]

Latest revision as of 19:55, 16 March 2014

Description

std.buffer.scopebuffer is a module authored by Walter Bright.

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.

Related links

Initial announcement / discussion

Ddoc Documentation

Current state

Under review

Initial discussion

concerns raised and answered

   Q: Why can't ScopeBuffer contain initial static array itself?
   A: 1) performance (fitting 2 registers -> faster passing to functions)
      2) avoid default-init of array
      3) more flexible (any memory block can be used)
      4) avoiding internal reference
   Q: How does it fit std.allocator?
   A: Current std.allocator shape is not clear enough to rely on it, ScopeBuffer is stand-alone
   Q: Why not use alloca to create buffer internally?
   A: alloca() cannot be used to allocate stack data in a function enclosing the current one

Various small implementation comments/issues have been adressed within linked pull request.

remaining concerns

  • Missing pre-generated documentation
  • Lack of documentation coverage
  • Some style differences from majority of "modern" Phobos
  • Relation with postblit-enabled types

Review 1

Related Links

Review thread