diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-03-13 05:30:01 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-03-13 05:30:01 +0100 |
| commit | f6cb7f3e7382a19a6d6d9990c243ffb8a666182d (patch) | |
| tree | dbf43f976f66a39fd87ffa38d59194b425efaa68 /src/znot.c | |
| parent | Make zabs, zneg and zswap inline (diff) | |
| download | libzahl-f6cb7f3e7382a19a6d6d9990c243ffb8a666182d.tar.gz libzahl-f6cb7f3e7382a19a6d6d9990c243ffb8a666182d.tar.bz2 libzahl-f6cb7f3e7382a19a6d6d9990c243ffb8a666182d.tar.xz | |
Optimisations
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/znot.c')
| -rw-r--r-- | src/znot.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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); } |
