From f6cb7f3e7382a19a6d6d9990c243ffb8a666182d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 13 Mar 2016 05:30:01 +0100 Subject: Optimisations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/znot.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/znot.c') diff --git a/src/znot.c b/src/znot.c index d0e52c0..e1b114c 100644 --- a/src/znot.c +++ b/src/znot.c @@ -5,25 +5,24 @@ void znot(z_t a, z_t b) { - size_t bits, n; + size_t bits, i; - if (zzero(b)) { + if (EXPECT(zzero(b), 0)) { SET_SIGNUM(a, 0); return; } bits = zbits(b); - SET(a, b); - SET_SIGNUM(a, -zsignum(a)); + a->used = b->used; + SET_SIGNUM(a, -zsignum(b)); - for (n = a->used; n--;) - a->chars[n] = ~(a->chars[n]); + for (i = 0; i < a->used; i++) + a->chars[i] = ~(b->chars[i]); bits = BITS_IN_LAST_CHAR(bits); if (bits) a->chars[a->used - 1] &= ((zahl_char_t)1 << bits) - 1; - while (a->used && !a->chars[a->used - 1]) - a->used--; + TRIM(a); if (!a->used) SET_SIGNUM(a, 0); } -- cgit v1.2.3-70-g09d2