Microoptimization in ResampleEffect.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 22 Sep 2015 23:34:58 +0000 (01:34 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 22 Sep 2015 23:34:58 +0000 (01:34 +0200)
resample_effect.cpp

index 1b74a96..156098e 100644 (file)
@@ -142,8 +142,9 @@ void normalize_sum(Tap<T>* vals, unsigned num)
                for (unsigned i = 0; i < num; ++i) {
                        sum += to_fp64(vals[i].weight);
                }
+               double inv_sum = 1.0 / sum;
                for (unsigned i = 0; i < num; ++i) {
-                       vals[i].weight = from_fp64<T>(to_fp64(vals[i].weight) sum);
+                       vals[i].weight = from_fp64<T>(to_fp64(vals[i].weight) * inv_sum);
                }
        }
 }