From 3d5c8056d9eb61b578e45457731014b97ec28956 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Thu, 5 Nov 2015 22:09:38 -0800 Subject: [PATCH] Premature optimization of MatchedFilter::shift_by_decimation_factor(). --- firmware/baseband/matched_filter.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/firmware/baseband/matched_filter.cpp b/firmware/baseband/matched_filter.cpp index 8f80d5e70..bd378c028 100644 --- a/firmware/baseband/matched_filter.cpp +++ b/firmware/baseband/matched_filter.cpp @@ -65,7 +65,24 @@ bool MatchedFilter::execute_once( } void MatchedFilter::shift_by_decimation_factor() { - std::move(&samples_[decimation_factor_], &samples_[taps_count_], &samples_[0]); + const sample_t* s = &samples_[decimation_factor_]; + sample_t* t = &samples_[0]; + + const size_t unroll_factor = 4; + size_t shift_count = (taps_count_ - decimation_factor_) / unroll_factor; + while(shift_count > 0) { + *t++ = *s++; + *t++ = *s++; + *t++ = *s++; + *t++ = *s++; + shift_count--; + } + + shift_count = (taps_count_ - decimation_factor_) % unroll_factor; + while(shift_count > 0) { + *t++ = *s++; + shift_count--; + } } } /* namespace matched_filter */