It is not about size. It is about value vs reference. A reference means that the CPU needs to get the value from the central memory, which is many many times slower than getting it from the cache or a register.

So if, as you pointed out, there is no big difference between the reference and the value itself, then you should use the value. Passing a double by const ref is not useful. It makes the code longer with absolutely zero runtime benefit.

On 8 Mar 2014, at 19:03, Enrique Fernández Perdomo<notifications@github.com> wrote:

> In diff_drive_controller/src/diff_drive_controller.cpp:
> 
> > @@ -193,8 +193,13 @@ static bool getWheelRadius(const boost::shared_ptr<const urdf::Link>& wheel_link
> >    void DiffDriveController::update(const ros::Time& time, const ros::Duration& period)
> >    {
> >      // COMPUTE AND PUBLISH ODOMETRY
> > +    const double& left_pos  = left_wheel_joint_.getPosition();
> I'd like to see if there's actually a penalty on using the reference.
> 
> I couldn't find any discussion about this now, but in principle double = 8bytes, double& = 4bytes/8bytes. In 64bit machines there shouldn't be any difference, so I've changed it.
> Sooner or later, we won't use 32bit, and still ---honestly--, I don't know if there's actually an advantage.
> 
> —
> Reply to this email directly or view it on GitHub.