(wrong string) ée

From: <git_AT_suckless.org>
Date: Wed, 4 May 2016 23:02:42 +0200 (CEST)

commit b0732b78f06a4b790f71517227d9e957751ad4fa
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Wed May 4 23:02:10 2016 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Wed May 4 23:02:10 2016 +0200

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

diff --git a/src/zadd.c b/src/zadd.c
index 934d63e..a78a918 100644
--- a/src/zadd.c
+++ b/src/zadd.c
_AT_@ -3,13 +3,13 @@
 
 
 static inline void
-zadd_impl(z_t a, z_t b, size_t n)
+zadd_impl_4(z_t a, z_t b, z_t c, size_t n)
 {
         zahl_char_t carry = 0, tcarry;
         size_t i;
 
         for (i = 0; i < n; i++) {
- tcarry = libzahl_add_overflow(a->chars + i, a->chars[i], b->chars[i]);
+ tcarry = libzahl_add_overflow(a->chars + i, b->chars[i], c->chars[i]);
                 carry = tcarry | (zahl_char_t)libzahl_add_overflow(a->chars + i, a->chars[i], carry);
         }
         while (carry) {
_AT_@ -22,6 +22,12 @@ zadd_impl(z_t a, z_t b, size_t n)
 }
 
 static inline void
+zadd_impl_3(z_t a, z_t b, size_t n)
+{
+ zadd_impl_4(a, a, b, n);
+}
+
+static inline void
 libzahl_zadd_unsigned(z_t a, z_t b, z_t c)
 {
         size_t size, n;
_AT_@ -45,21 +51,21 @@ libzahl_zadd_unsigned(z_t a, z_t b, z_t c)
                         n = c->used;
                         zmemset(a->chars + a->used, 0, n - a->used);
                 }
- zadd_impl(a, c, n);
+ zadd_impl_3(a, c, n);
         } else if (unlikely(a == c)) {
                 if (a->used < b->used) {
                         n = b->used;
                         zmemset(a->chars + a->used, 0, n - a->used);
                 }
- zadd_impl(a, b, n);
+ zadd_impl_3(a, b, n);
         } else if (likely(b->used > c->used)) {
- zmemcpy(a->chars, b->chars, b->used);
- a->used = b->used;
- zadd_impl(a, c, n);
+ zmemcpy(a->chars + n, b->chars + n, size - n);
+ a->used = size;
+ zadd_impl_4(a, b, c, n);
         } else {
- zmemcpy(a->chars, c->chars, c->used);
- a->used = c->used;
- zadd_impl(a, b, n);
+ zmemcpy(a->chars + n, c->chars + n, size - n);
+ a->used = size;
+ zadd_impl_4(a, b, c, n);
         }
 
         SET_SIGNUM(a, 1);
_AT_@ -93,7 +99,7 @@ zadd_unsigned_assign(z_t a, z_t b)
                 n = b->used;
                 zmemset(a->chars + a->used, 0, n - a->used);
         }
- zadd_impl(a, b, n);
+ zadd_impl_3(a, b, n);
 
         SET_SIGNUM(a, 1);
 }
Received on Wed May 04 2016 - 23:02:42 CEST

This archive was generated by hypermail 2.3.0 : Wed May 04 2016 - 23:12:14 CEST