Add more optimizations.
This commit is contained in:
parent
d757f3a79f
commit
4905391c82
@ -25,7 +25,7 @@ void deInitList(List *l) {
|
||||
}
|
||||
|
||||
void addToList(List *l, mpz_t n) {
|
||||
if(l->end == l->size) {
|
||||
if(unlikely(l->end == l->size)) {
|
||||
l->size += BLOCK_SIZE;
|
||||
if(unlikely(l->size == 0)) {
|
||||
fprintf(stderr,
|
||||
@ -33,7 +33,7 @@ void addToList(List *l, mpz_t n) {
|
||||
exit(1);
|
||||
}
|
||||
void *tmp = realloc(l->list, sizeof(mpz_t) * l->size);
|
||||
if(!tmp) {
|
||||
if(unlikely(!tmp)) {
|
||||
fprintf(stderr, "Failed to allocate more memory to list!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <gmp.h>
|
||||
|
||||
#include "list.h"
|
||||
#include "optimizers.h"
|
||||
|
||||
static bool run;
|
||||
void leave();
|
||||
@ -27,7 +28,7 @@ int main(void) {
|
||||
// Add 2, a known prime to this list
|
||||
mpz_set_ui(num, 2);
|
||||
addToList(&primes, num);
|
||||
if(mpz_out_str(stdout, 10, num) == 0) {
|
||||
if(unlikely(mpz_out_str(stdout, 10, num) == 0)) {
|
||||
fprintf(stderr, "Could not print to `stdout'!\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -43,7 +44,7 @@ int main(void) {
|
||||
|
||||
// `num' is a prime so we add it to the list and print it
|
||||
addToList(&primes, num);
|
||||
if(mpz_out_str(stdout, 10, num) == 0) {
|
||||
if(unlikely(mpz_out_str(stdout, 10, num) == 0)) {
|
||||
fprintf(stderr, "Could not print to `stdout'!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user