[Gmp-commit] /var/hg/gmp: Equivalent but maybe cleaner code.

mercurial at gmplib.org mercurial at gmplib.org
Sat Jan 9 21:38:13 UTC 2016


details:   /var/hg/gmp/rev/e6b3bc15fa5e
changeset: 17026:e6b3bc15fa5e
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat Jan 09 22:36:14 2016 +0100
description:
Equivalent but maybe cleaner code.

diffstat:

 primesieve.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (43 lines):

diff -r cad98dd22755 -r e6b3bc15fa5e primesieve.c
--- a/primesieve.c	Thu Jan 07 07:54:06 2016 +0100
+++ b/primesieve.c	Sat Jan 09 22:36:14 2016 +0100
@@ -199,15 +199,17 @@
     offset %= 182;
     SET_OFF2 (m21, m22, m23, SIEVE_2MSK1, SIEVE_2MSK2, SIEVE_2MSKT, offset, 182);
   }
+  /* THINK: Consider handling odd values of 'limbs' outside the loop,
+     to have a single exit condition. */
   do {
-    *bit_array = m11 | m21;
+    bit_array[0] = m11 | m21;
     if (--limbs == 0)
       break;
     ROTATE1 (m11, m12, 110);
-    *++bit_array = m11 | m22;
+    bit_array[1] = m11 | m22;
+    bit_array += 2;
     ROTATE1 (m11, m12, 110);
     ROTATE2 (m21, m22, m23, 182);
-    bit_array++;
   } while (--limbs != 0);
   return 4;
 #else
@@ -222,13 +224,15 @@
     offset %= 70;
     SET_OFF2 (mask, mask2, tail, SIEVE_MASK1, SIEVE_MASK2, SIEVE_MASKT, offset, 70);
   }
+  /* THINK: Consider handling odd values of 'limbs' outside the loop,
+     to have a single exit condition. */
   do {
-    *bit_array = mask;
+    bit_array[0] = mask;
     if (--limbs == 0)
       break;
-    *++bit_array = mask2;
+    bit_array[1] = mask2;
+    bit_array += 2;
     ROTATE2 (mask, mask2, tail, 70);
-    bit_array++;
   } while (--limbs != 0);
   return 2;
 #else


More information about the gmp-commit mailing list