Optimise if-statments in world2machine_clamp
Only one of the statements can be true: tmpx < X_MIN_POS or tmpx > X_MAX_POS. So we can be a little bit smarter here and skip the second if statement if the first was true. This saves 6 bytes of flash memory and potential some clock cycles
This commit is contained in:
parent
c0e7e17fc3
commit
53dfcf9d6f
|
|
@ -129,16 +129,15 @@ inline bool world2machine_clamp(float &x, float &y)
|
||||||
if (tmpx < X_MIN_POS) {
|
if (tmpx < X_MIN_POS) {
|
||||||
tmpx = X_MIN_POS;
|
tmpx = X_MIN_POS;
|
||||||
clamped = true;
|
clamped = true;
|
||||||
}
|
} else if (tmpx > X_MAX_POS) {
|
||||||
if (tmpy < Y_MIN_POS) {
|
|
||||||
tmpy = Y_MIN_POS;
|
|
||||||
clamped = true;
|
|
||||||
}
|
|
||||||
if (tmpx > X_MAX_POS) {
|
|
||||||
tmpx = X_MAX_POS;
|
tmpx = X_MAX_POS;
|
||||||
clamped = true;
|
clamped = true;
|
||||||
}
|
}
|
||||||
if (tmpy > Y_MAX_POS) {
|
|
||||||
|
if (tmpy < Y_MIN_POS) {
|
||||||
|
tmpy = Y_MIN_POS;
|
||||||
|
clamped = true;
|
||||||
|
} else if (tmpy > Y_MAX_POS) {
|
||||||
tmpy = Y_MAX_POS;
|
tmpy = Y_MAX_POS;
|
||||||
clamped = true;
|
clamped = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue