(wrong string) ée

From: <git_AT_suckless.org>
Date: Sat, 5 Mar 2016 22:33:58 +0100 (CET)

commit 64157e1d0e47a8b4e34817d77325fa09e1250b5f
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Sat Mar 5 20:42:34 2016 +0100
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Sat Mar 5 20:42:34 2016 +0100

    Improve zsub, only copy to temp when necessary
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/src/internals.h b/src/internals.h
index 9f276db..5c0ac32 100644
--- a/src/internals.h
+++ b/src/internals.h
_AT_@ -21,6 +21,7 @@
         X(libzahl_tmp_str_rem)\
         X(libzahl_tmp_gcd_u)\
         X(libzahl_tmp_gcd_v)\
+ X(libzahl_tmp_sub)\
         X(libzahl_tmp_modmul)\
         X(libzahl_tmp_div)\
         X(libzahl_tmp_mod)\
diff --git a/src/zsub.c b/src/zsub.c
index 5096eb0..cdb13f4 100644
--- a/src/zsub.c
+++ b/src/zsub.c
_AT_@ -17,17 +17,6 @@ zsub_unsigned(z_t a, z_t b, z_t c)
         } else if (zzero(c)) {
                 zabs(a, b);
                 return;
- } else if (a == b || a == c) {
- /* TODO This should not be necessary. */
- z_t tb, tc;
- zinit(tb);
- zinit(tc);
- zset(tb, b);
- zset(tc, c);
- zsub_unsigned(a, tb, tc);
- zfree(tb);
- zfree(tc);
- return;
         }
 
         magcmp = zcmpmag(b, c);
_AT_@ -36,13 +25,23 @@ zsub_unsigned(z_t a, z_t b, z_t c)
                         SET_SIGNUM(a, 0);
                         return;
                 }
+ n = MIN(b->used, c->used);
+ if (a == b) {
+ zset(libzahl_tmp_sub, b);
+ s = libzahl_tmp_sub->chars;
+ } else {
+ s = b->chars;
+ }
                 SET(a, c);
- n = MIN(a->used, b->used);
- s = b->chars;
         } else {
+ n = MIN(b->used, c->used);
+ if (a == c) {
+ zset(libzahl_tmp_sub, c);
+ s = libzahl_tmp_sub->chars;
+ } else {
+ s = c->chars;
+ }
                 SET(a, b);
- n = MIN(a->used, c->used);
- s = c->chars;
         }
 
         for (i = 0; i < n; i++) {
Received on Sat Mar 05 2016 - 22:33:58 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 05 2016 - 22:36:19 CET