aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/uhjfilter.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-03-14 17:21:19 -0700
committerChris Robinson <[email protected]>2018-03-14 17:27:41 -0700
commit7c0e68a33e1d25dfe4676f600c072e0f3edc2853 (patch)
tree755f9594a273529d85aa8556662327ba9540e182 /Alc/uhjfilter.c
parentf65e83c3499ed26ee3dea4b0a1ca0282d47ae7cc (diff)
Store the filter history in local variables
Despite being marked as restrict (and const for src) to mark the pointers as being non-aliased, it seems the compiler optimizes better this way.
Diffstat (limited to 'Alc/uhjfilter.c')
-rw-r--r--Alc/uhjfilter.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/Alc/uhjfilter.c b/Alc/uhjfilter.c
index 6f9fb37d..fd2d6567 100644
--- a/Alc/uhjfilter.c
+++ b/Alc/uhjfilter.c
@@ -22,14 +22,22 @@ static void allpass_process(AllPassState *state, ALfloat *restrict dst, const AL
if(LIKELY(todo > 1))
{
- dst[0] = aa*(src[0] + state->y[1]) - state->x[1];
- dst[1] = aa*(src[1] + state->y[0]) - state->x[0];
- for(i = 2;i < todo;i++)
- dst[i] = aa*(src[i] + dst[i-2]) - src[i-2];
- state->x[1] = src[i-2];
- state->x[0] = src[i-1];
- state->y[1] = dst[i-2];
- state->y[0] = dst[i-1];
+ ALfloat x0 = state->x[0];
+ ALfloat x1 = state->x[1];
+ ALfloat y0 = state->y[0];
+ ALfloat y1 = state->y[1];
+
+ for(i = 0;i < todo;i++)
+ {
+ dst[i] = aa*(src[i] + y1) - x1;
+ y1 = y0; y0 = dst[i];
+ x1 = x0; x0 = src[i];
+ }
+
+ state->x[0] = x0;
+ state->x[1] = x1;
+ state->y[0] = y0;
+ state->y[1] = y1;
}
else if(todo == 1)
{