Difference between revisions of "Std.buffer.scopebuffer"

From D Wiki
Jump to: navigation, search
(Created page with "== Description == [https://github.com/D-Programming-Language/phobos/pull/1911 std.buffer.scopebuffer] is a module authored by Walter Bright. <blockquote>ScopeBuffer is an Ou...")
 
(Add ddoc link)
Line 12: Line 12:
  
 
[http://forum.dlang.org/post/ld2586$17f6$1@digitalmars.com Initial announcement / discussion]
 
[http://forum.dlang.org/post/ld2586$17f6$1@digitalmars.com Initial announcement / discussion]
 +
 +
[http://www.walterbright.com/tmp/html/scopebuffer.html Ddoc Documentation]
  
 
== Current state ==
 
== Current state ==

Revision as of 08:50, 5 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

After preliminary discussion proposal is about to enter formal review process.

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