Use case: eliminate hidden allocations in buildPath

monarch_dodra monarchdodra at gmail.com
Thu Dec 5 13:53:19 PST 2013


On Thursday, 5 December 2013 at 20:47:32 UTC, Brad Anderson wrote:
> And thanks to your improvements[1] to put() output ranges 
> should actually be much more usable than they ever were before. 
> I've mentioned this a few times but I tried to add an output 
> range overload of toUpper and toLower but immediately 
> encountered problems with appending dchars to char arrays.  
> Your recently merged improvements to put() appear to have 
> addressed that problem and many others and I'll soon have 
> another go at adding these overloads now that that change is in 
> place so thanks for doing the hard work.
>
> Before this got merged I don't even think output ranges could 
> be easily used for this improvement to buildPath so it got 
> merged at a very convenient time.
>
> (my memory is a bit poor but if I'm remembering correctly 
> appender worked because it had done its own handling of narrow 
> strings but you couldn't just use a static or dynamic narrow 
> string array as an output range)
>
> 1. https://github.com/D-Programming-Language/phobos/pull/1569

Yes, appender did its own trans-coding, which helped the 
situation, but it made things like output delegates absolutely 
useless.

My next step was to *remove* the on the fly trancoding in 
appender, to rely only "put", directly, but I fear that would 
cause un-necessary breakge, due to UFCS not triggering if the 
member function exists:

In the sense that
put(appender!string(), myDstring); //Yes
appender!string().put(myDstring); //Nope


More information about the Digitalmars-d mailing list