diff options
| author | Mattias Andrée <maandree@kth.se> | 2016-04-30 05:47:05 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2016-04-30 05:47:05 +0200 |
| commit | 83d95da004c8cc2387a4070b781a71a0c6433faa (patch) | |
| tree | e5eaaa0e42bf7eeed461dc936bd2bed0600fb612 /zahl-inlines.h | |
| parent | Some optimisations (diff) | |
| download | libzahl-83d95da004c8cc2387a4070b781a71a0c6433faa.tar.gz libzahl-83d95da004c8cc2387a4070b781a71a0c6433faa.tar.bz2 libzahl-83d95da004c8cc2387a4070b781a71a0c6433faa.tar.xz | |
Some optimisations
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
| -rw-r--r-- | zahl-inlines.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/zahl-inlines.h b/zahl-inlines.h index 09e09a6..b69a8d2 100644 --- a/zahl-inlines.h +++ b/zahl-inlines.h @@ -19,6 +19,20 @@ ZAHL_INLINE void zabs(z_t a, z_t b) { ZAHL_SET(a, b); a->sign = !!a->sign; } ZAHL_INLINE void +zset(z_t a, z_t b) +{ + if (ZAHL_UNLIKELY(b->sign == 0)) { + a->sign = 0; + } else { + a->sign = b->sign; + a->used = b->used; + ZAHL_ENSURE_SIZE(a, b->used); + libzahl_memcpy(a->chars, b->chars, b->used); + } +} + + +ZAHL_INLINE void zswap(z_t a, z_t b) { /* Almost three times faster than the naïve method. */ |
