Phobos for Review: std.buffer.scopebuffer

Walter Bright newshound2 at digitalmars.com
Fri Feb 7 02:29:10 PST 2014


On 2/7/2014 2:02 AM, Lars T. Kyllingstad wrote:
> On Friday, 7 February 2014 at 09:38:56 UTC, Walter Bright wrote:
>> 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 don't understand.  Even if your workspace is stack-based or malloc-ed, you
> still need that one GC allocation for the return value, no?

If you have a path with 20 entries in it, and don't find the file, you do zero 
allocations instead of 20. If you find the file, that's do one allocation 
instead of 20/2 (on average), and you might be able to avoid that by passing it 
upwards, too :-)



More information about the Digitalmars-d mailing list