aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2020-12-21 07:22:26 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2020-12-21 07:22:55 +0100
commit3e544d6ec778fd1f9c4e425e279660fa6f66c3ac (patch)
tree692668f89c39feb811d65ec750c97d428d2fbda3
parentf079f913711091c87557a4c7854385c408e4ab7c (diff)
downloadbusybox-w32-3e544d6ec778fd1f9c4e425e279660fa6f66c3ac.tar.gz
busybox-w32-3e544d6ec778fd1f9c4e425e279660fa6f66c3ac.tar.bz2
busybox-w32-3e544d6ec778fd1f9c4e425e279660fa6f66c3ac.zip
factor: code shrink
function old new delta factor_main 176 171 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/factor.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/coreutils/factor.c b/coreutils/factor.c
index 30498c73b..1f9a13f94 100644
--- a/coreutils/factor.c
+++ b/coreutils/factor.c
@@ -49,12 +49,11 @@ typedef unsigned long half_t;
49 * (adding just one prime, 13, results in 5766 element sieve). 49 * (adding just one prime, 13, results in 5766 element sieve).
50 */ 50 */
51#define R(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J) \ 51#define R(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J) \
52 (((uint64_t)(a<<0) | (b<<3) | (c<<6) | (d<<9) | (e<<12) | (f<<15) | (g<<18) | (h<<21) | (i<<24) | (j<<27)) ) | \ 52 (((uint64_t)(a<<0) | (b<<3) | (c<<6) | (d<<9) | (e<<12) | (f<<15) | (g<<18) | (h<<21) | (i<<24) | (j<<27)) << 1) | \
53 (((uint64_t)(A<<0) | (B<<3) | (C<<6) | (D<<9) | (E<<12) | (F<<15) | (G<<18) | (H<<21) | (I<<24) | (J<<27)) << 30) | \ 53 (((uint64_t)(A<<0) | (B<<3) | (C<<6) | (D<<9) | (E<<12) | (F<<15) | (G<<18) | (H<<21) | (I<<24) | (J<<27)) << 31)
54 (((uint64_t)7 << 60))
55#define P(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J) \ 54#define P(a,b,c,d,e,f,g,h,i,j,A,B,C,D,E,F,G,H,I,J) \
56 R( (a/2-1),(b/2-1),(c/2-1),(d/2-1),(e/2-1),(f/2-1),(g/2-1),(h/2-1),(i/2-1),(j/2-1), \ 55 R( (a/2),(b/2),(c/2),(d/2),(e/2),(f/2),(g/2),(h/2),(i/2),(j/2), \
57 (A/2-1),(B/2-1),(C/2-1),(D/2-1),(E/2-1),(F/2-1),(G/2-1),(H/2-1),(I/2-1),(J/2-1) ) 56 (A/2),(B/2),(C/2),(D/2),(E/2),(F/2),(G/2),(H/2),(I/2),(J/2) )
58static const uint64_t packed_wheel[] = { 57static const uint64_t packed_wheel[] = {
59 /*1, 2, 2, 4, 2,*/ 58 /*1, 2, 2, 4, 2,*/
60 P( 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6, 8, 4), //01 59 P( 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6, 8, 4), //01
@@ -94,7 +93,7 @@ static const uint64_t packed_wheel[] = {
94 * wheel_tab - 485 +485 93 * wheel_tab - 485 +485
95 * 3-bit-packed insanity: 94 * 3-bit-packed insanity:
96 * packed_wheel - 192 +192 95 * packed_wheel - 192 +192
97 * factor_main 108 176 +68 96 * factor_main 108 176 +63
98 */ 97 */
99static void unpack_wheel(void) 98static void unpack_wheel(void)
100{ 99{
@@ -110,12 +109,12 @@ static void unpack_wheel(void)
110 p = &wheel_tab[5]; 109 p = &wheel_tab[5];
111 for (i = 0; i < ARRAY_SIZE(packed_wheel); i++) { 110 for (i = 0; i < ARRAY_SIZE(packed_wheel); i++) {
112 uint64_t v = packed_wheel[i]; 111 uint64_t v = packed_wheel[i];
113 do { 112 while ((v & 0xe) != 0) {
114 *p = ((unsigned)(v & 7) + 1) * 2; 113 *p = v & 0xe;
115 //printf("%2u,", *p); 114 //printf("%2u,", *p);
116 p++; 115 p++;
117 v >>= 3; 116 v >>= 3;
118 } while ((unsigned)v != 7); 117 }
119 //printf("\n"); 118 //printf("\n");
120 } 119 }
121} 120}