]> git.sesse.net Git - movit/commitdiff
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 1b74a965c6f60654967f5960fe3e69384256a78f..156098e993dbac47c2132c46dc7d1ed9348bb9c9 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);
                }
                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) {
                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);
                }
        }
 }
                }
        }
 }