Use case: eliminate hidden allocations in buildPath

Jonathan M Davis jmdavisProg at gmx.com
Wed Dec 4 17:02:20 PST 2013


On Wednesday, December 04, 2013 16:38:54 H. S. Teoh wrote:
> What about a new overload that takes an output range instead of
> returning a string?

I would have thought that that would be the obvious way to solve the problem. 
In general, I think that when a function allocates any kind of string or array 
which it returns, we should overload it with a version that takes an output 
range. In many cases, it would probably even make sense to make the default 
just use std.array.appender and make it so that only the output range overload 
is really doing any work.

What to do in cases of allocation where we're not dealing with arrays being 
returned is a tougher question, and I think that that starts going into custom 
allocator territory, but for arrays, output ranges are definitely the way to go 
IMHO.

- Jonathan M Davis


More information about the Digitalmars-d mailing list