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 :-)