From 5fc99de1f5542554ed02edb0b5f6f43ceea3c09d Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Tue, 25 Sep 2018 18:43:36 +0200 Subject: Improve code readability. --- src/new.c | 10 +++++----- src/new32.c | 10 +++++----- src/new32v2.c | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/new.c b/src/new.c index 3bdd6d0..0b223dc 100644 --- a/src/new.c +++ b/src/new.c @@ -9,16 +9,16 @@ static const uint64_t divtab[244] = { [243] = 0x010db20a + 1l }; -#define FASTDIV(n, C) (((n) * (C)) >> 32) -#define FASTMOD(n, d, C) ((n) - (d) * FASTDIV((n), (C))) +#define FASTDIV(n, d) (((n) * divtab[d]) >> 32) +#define FASTMOD(n, d) ((n) - (d) * FASTDIV((n), (d))) int new(int i, int x, int y) { uint64_t A, B, C; - A = FASTDIV(i, divtab[y]); - B = FASTMOD(A, 3, divtab[3]); - C = FASTMOD(A + (uint64_t)x, 3, divtab[3]); + A = FASTDIV(i, y); + B = FASTMOD(A, 3); + C = FASTMOD(A + (uint64_t)x, 3); return i + (C - B) * y; } diff --git a/src/new32.c b/src/new32.c index 9136115..654b793 100644 --- a/src/new32.c +++ b/src/new32.c @@ -9,16 +9,16 @@ static const unsigned int divtab[244] = { [243] = 0x010d + 1l }; -#define FASTDIV(n, C) (((n) * (C)) >> 16) -#define FASTMOD(n, d, C) ((n) - (d) * FASTDIV((n), (C))) +#define FASTDIV(n, d) (((n) * divtab[d]) >> 16) +#define FASTMOD(n, d) ((n) - (d) * FASTDIV((n), (d))) int new32(int i, int x, int y) { int A, B, C; - A = FASTDIV(i, divtab[y]); - B = FASTMOD(A, 3, divtab[3]); - C = FASTMOD(A + x, 3, divtab[3]); + A = FASTDIV(i, y); + B = FASTMOD(A, 3); + C = FASTMOD(A + x, 3); return i + (C - B) * y; } diff --git a/src/new32v2.c b/src/new32v2.c index a755d6d..1fd4c6f 100644 --- a/src/new32v2.c +++ b/src/new32v2.c @@ -9,7 +9,7 @@ static const unsigned int divtab[244] = { [243] = 0x010d + 1l }; -#define FASTDIV(n, d) (((n) * (divtab[d])) >> 16) +#define FASTDIV(n, d) (((n) * divtab[d]) >> 16) int new32v2(int i, int x, int y) { -- cgit