Phobos for Review: std.buffer.scopebuffer

Walter Bright newshound2 at digitalmars.com
Fri Feb 7 01:38:58 PST 2014


On 2/7/2014 1:13 AM, Lars T. Kyllingstad wrote:
> On Friday, 7 February 2014 at 08:24:39 UTC, Walter Bright wrote:
>> An output range like this is a precursor to eliminating the excessive gc use
>> by functions such as buildPath().
>
> Somewhat OT, but I think you should pick some other function than buildPath()
> for your examples.  It *used* to allocate east and west, yes, but that was a
> holdover from the old std.path.join(). I made some improvements to it about half
> a year ago, and now it virtually never allocates more than once(*).

I picked on buildPath() for a reason. The program I was writing did a lot of 
searching for files along a path, and by a lot I mean tens of thousands of times 
(!).

That one little 'ole allocation was murdering performance and generating vast 
amounts of garbage.

I wound up rewriting it to use ScopeBuffer, problem solved.

(Also, one of the lovely things about ScopeBuffer is it moves the action to the 
stack, which is hot in the cache.)


More information about the Digitalmars-d mailing list