std.stringbuffer

Sean Kelly sean at invisibleduck.org
Wed Apr 30 07:10:33 PDT 2008


== Quote from Janice Caron (caron800 at googlemail.com)'s article
> 2008/4/30 Sean Kelly <sean at invisibleduck.org>:
> >  Tango even exposes
> >  a GC.realloc() routine which will do this for you.
> So does Phobos. std.gc.realloc().
> However, realloc() doesn't promise not to copy, and not copying is the
> objective. Thanks for all the cool info, but I just think programmers
> would just feel more "comfortable" if, after they've done all their
> in-place string manipulations, they can call some minimizing function,
> even if only to give them a warm fuzzy feeling that they're not
> wasting any more memory than is necessary.

It's perhaps worth noting here that C++ objects don't typically minimize
either.  That's why Scott Meyers (?) proposed the idiom:

myVector.swap(std::vector(myVector));

> Frankly, it could even be implemented a do-nothing function. That way,
> at least "blame" for excessive memory use passes from the programmer
> to Phobos, and future gc implementations might do things differently.

Fair enough.


Sean



More information about the Digitalmars-d mailing list