[Development] Setters: Passing by value or const reference?

Olivier Goffart olivier at woboq.com
Wed Apr 25 23:06:07 CEST 2012


On Wednesday 25 April 2012 14:40:27 lars.knoll at nokia.com wrote:
> On 4/25/12 3:11 PM, "ext Olivier Goffart" <olivier at woboq.com> wrote:
> >On Wednesday 25 April 2012 13:47:35 Thiago Macieira wrote:
> >> However, I agree with you: it's too late to change it everywhere.
> >>
> >>Unless we
> >>
> >> do it properly, it also has the potential to make things worse. I'd
> >>
> >>like to
> >>
> >> ask you to find out where this is most important and do it now.
> >
> >My point was to make it the default policy for new setters rather then
> >changing existing code at this point.
> 
> One problem I see here is that this does to some extent make assumptions
> about the implementation of the getter. If we happen to have a need to
> change the implementation, the whole point of passing by value might
> suddenly become moot.
> 
> In addition it moves the code required for making the copy for the cases
> where the compiler can't optimize it away to the caller, ie. from a shared
> to a non shared location. This can increase the total size of the code
> generated.
> 
> So I'm absolutely not sure changing our policy is a good idea here. You
> might be optimizing one case and make many others worse.

That's right.
Let us ignore this, and keep it as before then :-)




More information about the Development mailing list