Boost logo

Boost :

From: Sam Partington (Sam.Partington_at_[hidden])
Date: 2002-08-30 11:32:17


> Rob Stewart wrote:
> >
> > Given that your demangling logic will be invoked in almost every
> > use case strictly for error reporting, performance is not an
> > issue. Therefore, any performance concern wrt copying strings is
> > moot.
>
> It's not just about performance. Errors may occur when the system is
> short of memory, thus you should try be avoid memory allocations
> whenever possible (OK, string will most likely not be a real problem,
> put you never know...).

Yes, but like as not the act of appending to the string will cause it's
buffer too overflow, and the whole string will have to be copied anyway, or
perhaps the string was shared, and had to be copied on write. At least with
the return string method you get predictable copies.

Seems to me this is a minor thing to worry about, but return by reference is
always semantically more correct for my brain. I've always disliked the MFC
library for returning by reference all the time. They do that because they
communicate failure through a BOOL, but we have exceptions, so I don't see
the need.

But at the end of the day, as long as the interface is complete, minimal,
and consistent, thats fine. (Come to think of it, boost does fairly
consistently return by value)

sam


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk