3 ms·
Does this generate slower code? No, or at least not with an optimizing compiler. It was probably more about writing compact code. Personally, I'd have used ab
by cygx 14y ago
Does this generate slower code?
No, or at least not with an optimizing compiler. It was probably more about writing compact code.
Personally, I'd have used abs() and gotten rid of the temporary variable dd altogether:
int SATD (void)
{
int satd = 0, k;
for (k = 0; k < sizeof d / sizeof *d; ++k)
satd += abs(d[k]);
return satd;
}
- mansr 14y agoGood thinking. Most modern compilers will recognise abs() and generate efficient code.