On 24 May 2013 15:44, Jonathan M Davis <jmdavisp...@gmx.com> wrote: > On Friday, May 24, 2013 15:37:39 Manu wrote: > > I'd say a majority of phobos > > allocations are created when passing strings through to library/system > > calls. > > That does sound probable, as toStringz will often (and unpredictably) > result > in allocations, and it does seem like a prime location for at least > attempting > to use a static array instead as you suggested. But if toStringz _wouldn't_ > result in an allocation, then copying to a static array would be > inadvisable, > so we're probably going to need a function which does toStringz's test so > that > it can be used outside of toStringz. >
Yeah, an alloca based cstring helper which performs the zero-terminate check, then if it's not terminated, and short enough, alloca and copy, else if too long, new. I'm sure that would be a handy little template, and improve phobos a lot.