From 2672a88a897b052fa138922e665f31028c4d353c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 26 Dec 2015 08:55:23 +0100 Subject: [PATCH] DRY more --- src/vec_match.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/vec_match.c b/src/vec_match.c index a3d6fae..c814c13 100644 --- a/src/vec_match.c +++ b/src/vec_match.c @@ -53,23 +53,15 @@ bool vec_match_do(const float *data, const float *ref, uint32_t ref_p_len, } // find base and peak - if (packed) { - for (uint32_t j = a; j <= b; j++) { - f = pw_get(&w, j); - if (peak < f) peak = f; - if (base > f) base = f; - } - ref_at = pw_get(&w, i); - } else { - for (uint32_t j = a; j <= b; j++) { - if (peak < ref[j]) peak = ref[j]; - if (base > ref[j]) base = ref[j]; - } + for (uint32_t j = a; j <= b; j++) { + f = packed ? pw_get(&w, j) : ref[j]; - ref_at = ref[i]; + if (peak < f) peak = f; + if (f < base) base = f; } + ref_at = packed ? pw_get(&w, i) : ref[i]; // apply drift_y peak += cfg->offset_y; // add abs threshold on top @@ -94,7 +86,7 @@ bool vec_match_do(const float *data, const float *ref, uint32_t ref_p_len, } } - // write error values to provided fields +// write error values to provided fields if (fuzzy_match_error != NULL) *fuzzy_match_error = env_err; if (abs_match_error != NULL) *abs_match_error = abs_err;