kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit e946a12056ddb28f01adcdeaad94b6eba166868d
parent ea10f68968ee3e94b9f1030320eda831514d5598
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Fri,  4 Nov 2016 03:12:52 +0300

expression_pointer: pass vec by reference

Diffstat:
Minclude/kfr/base/pointer.hpp | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/kfr/base/pointer.hpp b/include/kfr/base/pointer.hpp @@ -80,13 +80,15 @@ struct expression_pointer : input_expression template <size_t N> CMT_INLINE vec<T, N> operator()(cinput_t, size_t index, vec_t<T, N>) const { - using func_t = vec<T, N> (*)(void*, size_t); + using func_t = void (*)(void*, size_t, vec<T, N>&); static_assert(is_poweroftwo(N), "N must be a power of two"); constexpr size_t findex = ilog2(N); static_assert(N <= maximum_expression_width, "N is greater than maxwidth"); func_t func = reinterpret_cast<func_t>((*vtable)[2 + findex]); - return func(instance, index); + vec<T, N> result; + func(instance, index, result); + return result; } CMT_INLINE void begin_block(cinput_t, size_t size) const { @@ -120,13 +122,15 @@ struct expression_pointer<T, false> : input_expression template <size_t N> CMT_INLINE vec<T, N> operator()(cinput_t, size_t index, vec_t<T, N>) const { - using func_t = vec<T, N> (*)(void*, size_t); + using func_t = void (*)(void*, size_t, vec<T, N>&); static_assert(is_poweroftwo(N), "N must be a power of two"); constexpr size_t findex = ilog2(N); static_assert(N <= maximum_expression_width, "N is greater than maxwidth"); func_t func = reinterpret_cast<func_t>((*vtable)[2 + findex]); - return func(instance, index); + vec<T, N> result; + func(instance, index, result); + return result; } CMT_INLINE void begin_block(cinput_t, size_t size) const { @@ -149,11 +153,11 @@ private: namespace internal { template <typename T, size_t N, typename Fn, typename Ret = vec<T, N>, - typename NonMemFn = Ret (*)(void*, size_t)> + typename NonMemFn = void (*)(void*, size_t, Ret&)> CMT_INLINE NonMemFn make_expression_func() { - return [](void* fn, size_t index) -> Ret { - return (reinterpret_cast<Fn*>(fn)->operator()(cinput, index, vec_t<T, N>())); + return [](void* fn, size_t index, Ret& result) { + result = (reinterpret_cast<Fn*>(fn)->operator()(cinput, index, vec_t<T, N>())); }; }