toString refactor in druntime

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Sat Nov 1 05:31:14 PDT 2014


On Saturday, 1 November 2014 at 07:02:03 UTC, Walter Bright wrote:
> On 10/30/2014 8:30 AM, Steven Schveighoffer wrote:
>> This is a typical mechanism that Tango used -- pass in a ref 
>> to a dynamic array
>> referencing a stack buffer. If it needed to grow, just update 
>> the length, and it
>> moves to the heap. In most cases, the stack buffer is enough. 
>> But the idea is to
>> try and minimize the GC allocations, which are performance 
>> killers on the
>> current platforms.
>
> We keep solving the same problem over and over. 
> std.internal.scopebuffer does this handily. It's what it was 
> designed for - it works, it's fast, and it virtually eliminates 
> the need for heap allocations. Best of all, it's an Output 
> Range, meaning it fits in with the range design of Phobos.

It is not the same thing as ref/out buffer argument. We have been 
running ping-pong comments about it for a several times now. All 
std.internal.scopebuffer does is reducing heap allocation count 
at cost of stack consumption (and switching to raw malloc for 
heap) - it does not change big-O estimate of heap allocations 
unless it is used as a buffer argument - at which point it is no 
better than plain array.


More information about the Digitalmars-d mailing list