From deec79ce61b8661d3ad76f3ecc10a80d1ce19cdd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 9 Apr 2017 17:33:31 +0200 Subject: Clean up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-arithm.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'src/blind-arithm.c') diff --git a/src/blind-arithm.c b/src/blind-arithm.c index bc30bee..613783e 100644 --- a/src/blind-arithm.c +++ b/src/blind-arithm.c @@ -25,34 +25,23 @@ typedef void (*process_func)(struct stream *left, struct stream *right, size_t n X(div, *lh /= rh)\ X(exp, *lh = pow(*lh, rh))\ X(log, *lh = log(*lh) / log(rh))\ - X(min, *lh = *lh < rh ? *lh : rh)\ - X(max, *lh = *lh > rh ? *lh : rh)\ + X(min, *lh = MIN(*lh, rh))\ + X(max, *lh = MAX(*lh, rh))\ X(abs, *lh = fabs(*lh - rh) + rh) +#define C(CH, CHI, ALGO)\ + (!skip_##CH ? ((lh = ((double *)(left->buf + i)) + (CHI),\ + rh = ((double *)(right->buf + i))[CHI],\ + (ALGO)), 0) : 0) + #define X(NAME, ALGO)\ static void\ process_lf_##NAME(struct stream *left, struct stream *right, size_t n)\ {\ size_t i;\ double *lh, rh;\ - for (i = 0; i < n; i += 4 * sizeof(double)) {\ - if (!skip_x) {\ - lh = ((double *)(left->buf + i)) + 0, rh = ((double *)(right->buf + i))[0];\ - ALGO;\ - }\ - if (!skip_y) {\ - lh = ((double *)(left->buf + i)) + 1, rh = ((double *)(right->buf + i))[1];\ - ALGO;\ - }\ - if (!skip_z) {\ - lh = ((double *)(left->buf + i)) + 2, rh = ((double *)(right->buf + i))[2];\ - ALGO;\ - }\ - if (!skip_a) {\ - lh = ((double *)(left->buf + i)) + 3, rh = ((double *)(right->buf + i))[3];\ - ALGO;\ - }\ - }\ + for (i = 0; i < n; i += 4 * sizeof(double))\ + C(x, 0, ALGO), C(y, 1, ALGO), C(z, 2, ALGO), C(a, 3, ALGO);\ } LIST_OPERATORS #undef X -- cgit v1.2.3-70-g09d2