From 645c0e312389d15c6661c152ce9635183e9ca307 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 23 Sep 2015 01:34:58 +0200 Subject: [PATCH] Microoptimization in ResampleEffect. --- resample_effect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resample_effect.cpp b/resample_effect.cpp index 1b74a96..156098e 100644 --- a/resample_effect.cpp +++ b/resample_effect.cpp @@ -142,8 +142,9 @@ void normalize_sum(Tap* 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(to_fp64(vals[i].weight) / sum); + vals[i].weight = from_fp64(to_fp64(vals[i].weight) * inv_sum); } } } -- 2.39.2