Browse Source

Lookup table also inside for loop.

Michele Orrù 7 years ago
parent
commit
3158ec5cc3
2 changed files with 4 additions and 6 deletions
  1. 4 3
      src/ddlog.c
  2. 0 3
      src/timeit.h

+ 4 - 3
src/ddlog.c

@@ -69,9 +69,9 @@ uint32_t convert(uint64_t * nn)
 
     for (uint32_t w2 = halfstrip_size; w2 < 64-halfstrip_size; w2 += halfstrip_size) {
       if (!(y & (topmask >> w2))) {
-        for (w = w2-1; !(y & (topmask >> w)); w--);
-        ++w;
-        if (!(y & (topbigmask >> w)))  return steps + w;
+        const size_t previous = (y >> (64 - halfstrip_size - w2 + halfstrip_size)) & bottommask;
+        const uint8_t next =    (y >> (64 - halfstrip_size - w2 - halfstrip_size)) & bottommask;
+        if (next <= lookup[previous]) return steps + w2 - offset[previous];
       }
     }
 
@@ -89,6 +89,7 @@ uint32_t convert(uint64_t * nn)
   return steps;
 }
 
+
 uint32_t naif_convert(mpz_t n)
 {
   uint32_t i;

+ 0 - 3
src/timeit.h

@@ -17,6 +17,3 @@
   __sdiff + __udiff * 1e-9
 
 #define TIMEIT_FORMAT "%lf"
-
-
-#define INIT_CLOCK