Hello,

somewhen during the translations I the posemaths routine popped up IIRC and I 
had wondered about the passing by value of those doubles. For 64bit machines 
this likely does not make too much of a difference, and the compilers are not 
stupid either, but for 32bit machines and without link-time optimisation, I 
guess it helps when the value does not need to be copied.

My routines have this already, especially for the non-scalar values, like
src//libnml/posemath/posemath.cc:// PM_POSE class
src//libnml/posemath/posemath.cc:PM_POSE inv(const PM_POSE &p)
src//libnml/posemath/posemath.cc:    PM_POSE ret;
src//libnml/posemath/posemath.cc:PM_POSE operator +(const PM_POSE &p)
src//libnml/posemath/posemath.cc:PM_POSE operator -(const PM_POSE &p)
src//libnml/posemath/posemath.cc:    PM_POSE ret;
src//libnml/posemath/posemath.cc:int operator ==(const PM_POSE &p1, const 
PM_POSE &p2)
src//libnml/posemath/posemath.cc:int operator !=(const PM_POSE &p1, const 
PM_POSE &p2)
src//libnml/posemath/posemath.cc:PM_POSE operator *(const PM_POSE &p1, 
const PM_POSE &p2)
src//libnml/posemath/posemath.cc:PM_POSE::PM_POSE(PM_CCONST PM_POSE & p)
src//libnml/posemath/posemath.cc:PM_HOMOGENEOUS::PM_HOMOGENEOUS(PM_CONST 
PM_POSE PM_REF p)

but others very much not so, like

src//libnml/posemath/posemath.cc:PM_POSE::PM_POSE(PM_CARTESIAN v, PM_QUATERNION 
q)
src//libnml/posemath/posemath.cc:PM_POSE::PM_POSE(double x, double y, double z,
src//libnml/posemath/posemath.cc:int PM_LINE::init(PM_POSE start, PM_POSE end)
src//libnml/posemath/posemath.cc:int PM_LINE::point(double len, PM_POSE * point)
src//libnml/posemath/posemath.cc:int PM_CIRCLE::init(PM_POSE start, PM_POSE end,
src//libnml/posemath/posemath.cc:int PM_CIRCLE::point(double angle, PM_POSE * 
point)

so I suggest I look at them all and transform

PM_CARTESIAN::PM_CARTESIAN(double _x, double _y, double _z)
{
    x = _x;
    y = _y;
    z = _z;
}

to

PM_CARTESIAN::PM_CARTESIAN(const double& _x, const double& _y, const 
double& _z)
{
    x = _x;
    y = _y;
    z = _z;
}

and for

PM_ROTATION_MATRIX::PM_ROTATION_MATRIX(double xx, double xy, double xz,
    double yx, double yy, double yz, double zx, double zy, double zz)

well - the number of circles saved sum up :)

Would this be considered worthwhile to be addressed?

Now, even though it is just an introduction of "const" and "&", and we have 
our peer review, there is a chance I mess something up with these low-level 
routines. I should hence also come up with some tests, right? And better I have 
the tests prior to change.

Comments?

Best,
Steffen





_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to