(wrong string) ée

From: <git_AT_suckless.org>
Date: Sat, 12 Mar 2016 20:41:49 +0100 (CET)

commit 5e77b994435be4bef66ff596bf931e1fff97a77c
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Sat Mar 12 20:22:11 2016 +0100
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Sat Mar 12 20:22:11 2016 +0100

    64-bit chars out-perform 32-bit chars on almost all operations, and on all expensive operations
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/src/internals.h b/src/internals.h
index 8a9c379..b4e6039 100644
--- a/src/internals.h
+++ b/src/internals.h
_AT_@ -5,9 +5,9 @@
 #include <stdlib.h>
 #include <errno.h>
 
-#define BITS_PER_CHAR 32
-#define LB_BITS_PER_CHAR 5
-#define ZAHL_CHAR_MAX UINT32_MAX
+#define BITS_PER_CHAR 64
+#define LB_BITS_PER_CHAR 6
+#define ZAHL_CHAR_MAX UINT64_MAX
 
 #define FLOOR_BITS_TO_CHARS(bits) ((bits) >> LB_BITS_PER_CHAR)
 #define CEILING_BITS_TO_CHARS(bits) (((bits) + (BITS_PER_CHAR - 1)) >> LB_BITS_PER_CHAR)
diff --git a/src/zsets.c b/src/zsets.c
index 2b91864..fb44db4 100644
--- a/src/zsets.c
+++ b/src/zsets.c
_AT_@ -41,9 +41,6 @@ zsets(z_t a, const char *str)
                         if (!temp)
                                 continue;
                         libzahl_tmp_str_num->chars[0] = (zahl_char_t)temp;
- temp >>= BITS_PER_CHAR;
- libzahl_tmp_str_num->chars[1] = (zahl_char_t)temp;
- libzahl_tmp_str_num->used = 1 + !!temp;
                         zadd(a, a, libzahl_tmp_str_num);
                 }
         }
diff --git a/src/zsetu.c b/src/zsetu.c
index 37fbf7c..538ea37 100644
--- a/src/zsetu.c
+++ b/src/zsetu.c
_AT_@ -13,9 +13,6 @@ zsetu(z_t a, unsigned long long int b)
         }
         ENSURE_SIZE(a, SIZE_MULTIPLE(b, *(a->chars)));
         SET_SIGNUM(a, 1);
- a->used = 0;
- while (b) {
- a->chars[a->used++] = (zahl_char_t)b;
- b >>= BITS_PER_CHAR;
- }
+ a->chars[0] = (zahl_char_t)b;
+ a->used = 1;
 }
diff --git a/src/zstr.c b/src/zstr.c
index f7273ce..81a9674 100644
--- a/src/zstr.c
+++ b/src/zstr.c
_AT_@ -6,16 +6,16 @@
 #define num libzahl_tmp_str_num
 #define rem libzahl_tmp_str_rem
 
-/* All 9 you see here is derived from that 10⁹ is the largest
- * power of than < 2³², and 32 is the number of bits in
- * zahl_char_t. If zahl_char_t is chanced, the value 9, and
- * the cast to unsigned long must be changed accordingly. */
+/* All 19 you see here is derived from that 10¹⁹ is the largest
+ * power of than < 2⁶⁴, and 64 is the number of bits in
+ * zahl_char_t. If zahl_char_t is chanced, the value 19, and
+ * the cast to unsigned long long must be changed accordingly. */
 
 
 char *
 zstr(z_t a, char *b)
 {
- char buf[9 + 1];
+ char buf[19 + 1];
         size_t n, len;
         char overridden = 0;
         int neg;
_AT_@ -44,17 +44,17 @@ zstr(z_t a, char *b)
         b[0] = '-';
         b += neg;
         n -= neg;
- n = n > 9 ? (n - 9) : 0;
+ n = n > 19 ? (n - 19) : 0;
 
         for (;;) {
- zdivmod(num, rem, num, libzahl_const_1e9);
+ zdivmod(num, rem, num, libzahl_const_1e19);
                 if (!zzero(num)) {
- sprintf(b + n, "%09lu", zzero(rem) ? 0UL : (unsigned long)(rem->chars[0]));
- b[n + 9] = overridden;
+ sprintf(b + n, "%019llu", zzero(rem) ? 0ULL : (unsigned long long)(rem->chars[0]));
+ b[n + 19] = overridden;
                         overridden = b[n];
- n = n > 9 ? (n - 9) : 0;
+ n = n > 19 ? (n - 19) : 0;
                 } else {
- len = (size_t)sprintf(buf, "%lu", (unsigned long)(rem->chars[0]));
+ len = (size_t)sprintf(buf, "%llu", (unsigned long long)(rem->chars[0]));
                         if (overridden)
                                 buf[len] = b[n + len];
                         memcpy(b + n, buf, len + 1);
diff --git a/zahl.h b/zahl.h
index 4cb1373..f537c23 100644
--- a/zahl.h
+++ b/zahl.h
_AT_@ -11,7 +11,7 @@
 
 
 /* You should pretend like this typedef does not exist. */
-typedef uint32_t zahl_char_t;
+typedef uint64_t zahl_char_t;
 
 /* This structure should be considered opaque. */
 typedef struct {
Received on Sat Mar 12 2016 - 20:41:49 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 12 2016 - 20:48:13 CET