(wrong string) ée

From: <git_AT_suckless.org>
Date: Thu, 3 Mar 2016 14:00:17 +0100 (CET)

commit 6cc727a4a17c6b037f665433cc47b37aa926b92b
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Thu Mar 3 12:52:25 2016 +0100
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Thu Mar 3 12:52:25 2016 +0100

    Optimise zdivmod
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/src/internals.h b/src/internals.h
index db45a3b..89d98e1 100644
--- a/src/internals.h
+++ b/src/internals.h
_AT_@ -26,8 +26,7 @@
         X(libzahl_tmp_modsqr)\
         X(libzahl_tmp_divmod_a)\
         X(libzahl_tmp_divmod_b)\
- X(libzahl_tmp_divmod_d)\
- X(libzahl_tmp_divmod_e)
+ X(libzahl_tmp_divmod_d)
 
 #define LIST_CONSTS\
         X(libzahl_const_1e19, zsetu, 10000000000000000000ULL) /* The largest power of 10 < 2⁶⁴. */\
diff --git a/src/zdivmod.c b/src/zdivmod.c
index c25ae49..052e343 100644
--- a/src/zdivmod.c
+++ b/src/zdivmod.c
_AT_@ -4,13 +4,12 @@
 #define ta libzahl_tmp_divmod_a
 #define tb libzahl_tmp_divmod_b
 #define td libzahl_tmp_divmod_d
-#define te libzahl_tmp_divmod_e
 
 
 void
 zdivmod(z_t a, z_t b, z_t c, z_t d)
 {
- size_t c_bits, d_bits, shift;
+ size_t c_bits, d_bits, bit;
         int sign, cmpmag;
 
         sign = zsignum(c) * zsignum(d);
_AT_@ -47,25 +46,24 @@ zdivmod(z_t a, z_t b, z_t c, z_t d)
         c_bits = zbits(c);
         d_bits = zbits(d);
 
- shift = c_bits - d_bits;
- zlsh(td, d, shift);
+ bit = c_bits - d_bits;
+ zlsh(td, d, bit);
         SET_SIGNUM(td, 1);
         if (zcmpmag(td, c) > 0) {
                 zrsh(td, td, 1);
- shift -= 1;
+ bit -= 1;
         }
 
- zsetu(te, 1);
- zlsh(te, te, shift);
         SET_SIGNUM(ta, 0);
         zabs(tb, c);
 
- while (!zzero(te)) {
+ for (;;) {
                 if (zcmpmag(td, tb) <= 0) {
                         zsub(tb, tb, td);
- zor(ta, ta, te);
+ zbset(ta, ta, bit, 1);
                 }
- zrsh(te, te, 1);
+ if (!bit--)
+ break;
                 zrsh(td, td, 1);
         }
 
Received on Thu Mar 03 2016 - 14:00:17 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 03 2016 - 14:12:21 CET