From dab78093abc21e9a434b35c1213c64afc44c2e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Sat, 10 Dec 2016 17:11:21 +0100 Subject: [PATCH] Deleted macros --- src/list.c | 8 +++----- src/main.c | 10 ++++------ src/optimizers.h | 3 --- 3 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 src/optimizers.h diff --git a/src/list.c b/src/list.c index 070edb6..81182f7 100644 --- a/src/list.c +++ b/src/list.c @@ -2,8 +2,6 @@ #include #include -#include "optimizers.h" - /** * This is the number of elements by which the list expands. * WARNING: Always use doubles for this number (2^X) @@ -28,14 +26,14 @@ void deInitList(List *l) { } void addToList(List *l, mpz_t n) { - if(unlikely(l->end == l->size)) { + if(l->end == l->size) { l->size += BLOCK_SIZE; - if(unlikely(l->size == 0)) { + if(l->size == 0) { fprintf(stderr, "`l->size' has overflowed!\n"); exit(1); } void *tmp = realloc(l->list, sizeof(mpz_t) * l->size); - if(unlikely(!tmp)) { + if(!tmp) { fprintf(stderr, "Failed to allocate more memory to list!\n"); exit(1); } diff --git a/src/main.c b/src/main.c index 826c9dc..c6c80ec 100644 --- a/src/main.c +++ b/src/main.c @@ -6,13 +6,12 @@ #include "list.h" #include "types.h" -#include "optimizers.h" static bool run; void leave(); int main(void) { - printf("Indivisible v0.2\n"); + puts("Indivisible v0.2\n"); // Quit on ^C by setting `run = false' run = true; @@ -44,9 +43,8 @@ int main(void) { // Calculate half of `num' mpz_fdiv_q_ui(halfNum, num, 2); // Loop through found primes - for(ulli i = 0; i < primes.size; ++i) { - // If the prime we're looking at is >= half of `num' then we can skip the rest - if(mpz_cmp(primes.list[i], halfNum) >= 0) break; + // Skip 2 because we're skipping even nymbers + for(ulli i = 1; mpz_cmp(primes.list[i], halfNum) >= 0; ++i) { // If `num' is divisible by a prime then go to the next number if(mpz_divisible_p(num, primes.list[i]) != 0) goto nextPrime; @@ -74,6 +72,6 @@ nextPrime: } void leave() { - printf("Exiting...\n"); + puts("Exiting...\n"); run = false; } diff --git a/src/optimizers.h b/src/optimizers.h deleted file mode 100644 index c743819..0000000 --- a/src/optimizers.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0)