diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-03-14 20:51:37 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-03-14 20:51:37 +0100 |
| commit | 1ec80039288073294e3e61b0c680e9c95688e786 (patch) | |
| tree | 3d07a351a42e89f734bb3b24bc349e950fd45e11 /zahl.h | |
| parent | Mostly optimisations (diff) | |
| download | libzahl-1ec80039288073294e3e61b0c680e9c95688e786.tar.gz libzahl-1ec80039288073294e3e61b0c680e9c95688e786.tar.bz2 libzahl-1ec80039288073294e3e61b0c680e9c95688e786.tar.xz | |
Optimise zswap
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'zahl.h')
| -rw-r--r-- | zahl.h | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -189,7 +189,6 @@ void zperror(const char *); /* Identical to perror(3p) except it sup ZAHL_INLINE void zinit(z_t a) { a->alloced = 0; a->chars = 0; } -ZAHL_INLINE void zswap(z_t a, z_t b) { z_t t; *t = *a; *a = *b; *b = *t; } ZAHL_INLINE int zeven(z_t a) { return !a->sign || !(a->chars[0] & 1); } ZAHL_INLINE int zodd(z_t a) { return a->sign && (a->chars[0] & 1); } ZAHL_INLINE int zeven_nonzero(z_t a) { return !(a->chars[0] & 1); } @@ -201,6 +200,25 @@ ZAHL_INLINE void zneg(z_t a, z_t b) { if (a != b) zset(a, b); a->sign = -a->si ZAHL_INLINE void +zswap(z_t a, z_t b) +{ + z_t t; + t->sign = a->sign; + a->sign = b->sign; + b->sign = t->sign; + t->used = b->used; + b->used = a->used; + a->used = t->used; + t->alloced = a->alloced; + a->alloced = b->alloced; + b->alloced = t->alloced; + t->chars = b->chars; + b->chars = a->chars; + a->chars = t->chars; +} + + +ZAHL_INLINE void zseti(z_t a, int64_t b) { if (ZAHL_UNLIKELY(b >= 0)) { |
