Re:Going Faster by Duplicating Code
by ape4 on Tuesday October 10, 2023 @11:04PM
(#37840419)
Honest question, would `V *= Factor` be faster?
[ Parent
| on HN ]
In almost all cases: no.
"A compound assignment of the form E1 op= E2 differs from the simple assignment expression E1 = E1 op (E2) only in that the lvalue E1 is evaluated only once." (C99, 6.5.16.2p3)
It only matters when evaluating E1 has side effects. For example, `a[i++] += 1;` which is equivalent to `a[i] = a[i] + 1; i++;` rather than `a[i++] = a[i++] + 1;`.
> `a[i++] = a[i++] + 1;`
This is probably not what you want, as "i" is increased twice.