Copy-by-value in sdbus++ generated objects

Lei YU mine260309 at gmail.com
Mon Nov 5 13:36:27 AEDT 2018


On Sat, Nov 3, 2018 at 12:33 AM Patrick Venture <venture at google.com> wrote:
>
> Most repos inherit from an auto-generated object.  Those objects pass
> all parameters by value.  This is fine for many cases where they would
> need to create a copy of it, but in the case where:
>
> for instance:
> https://github.com/openbmc/sdbusplus/blob/master/tools/sdbusplus/templates/property.mako.prototype.hpp.in#L69
>
> The values match it's wasteful to copy.  It's also possible the cpp I
> learned way back is different in how this behavior works, but I wanted
> to check.  Because of the prevalence of this code, if there are lots
> of updates that don't actually change the value, it could optimize
> quite a bit at run-time.

Agreed, this piece of code does not change the value at all, so it is better
to use const reference.

>
> It would require a lot of simultaneous fixes (or two different objects
> generated, and transitioning everything).
>
> Thoughts?

Maybe we could try to change this to const reference, do a build and see if it
cause any build error.
I guess this is OK.


More information about the openbmc mailing list