On Friday, 26 February 2021 at 03:57:12 UTC, tsbockman wrote:
  static foreach(size_t i; 0 .. 3/+typeof(a).length+/){
      distance += a[i].abs;//abs required by the caller

(a * a) above is always positive for real numbers. You don't need the call to abs unless you're trying to guarantee that even nan values will have a clear sign bit.

I do not know why but the caller's performance nosedives whenever there is no .abs at this particular line.(there's a 3x difference, no joke.) Same for assignment instead of addition, but with a 2x difference instead.

Reply via email to