Skip to content
Permalink
Browse files

Refactor

  • Loading branch information
kimwalisch committed Dec 18, 2019
1 parent 68f05b4 commit 565d48a5603cbace86022ad4805b760c85332664
Showing with 6 additions and 5 deletions.
  1. +4 −4 src/PrimeGenerator.cpp
  2. +2 −1 src/PrintPrimes.cpp
@@ -293,7 +293,7 @@ void PrimeGenerator::fill(vector<uint64_t>& primes,

// Use local variables to prevent the compiler from
// writing temporary results to memory.
size_t num = 0;
size_t i = 0;
size_t maxSize = primes.size();
assert(maxSize >= 64);
uint64_t low = low_;
@@ -310,17 +310,17 @@ void PrimeGenerator::fill(vector<uint64_t>& primes,
uint64_t bits = littleendian_cast<uint64_t>(&sieve[sieveIdx]);

for (; bits != 0; bits &= bits - 1)
primes[num++] = nextPrime(bits, low);
primes[i++] = nextPrime(bits, low);

low += 8 * 30;
sieveIdx += 8;
}
while (num <= maxSize - 64 &&
while (i <= maxSize - 64 &&
sieveIdx < sieveSize);

low_ = low;
sieveIdx_ = sieveIdx;
*size = num;
*size = i;
}
while (*size == 0);
}
@@ -176,7 +176,8 @@ void PrintPrimes::printkTuplets() const
uint64_t low = low_;
ostringstream kTuplets;

for (; !ps_.isPrint(i); i++);
while (!ps_.isPrint(i))
i++;

for (uint64_t j = 0; j < sieveSize_; j++, low += 30)
{

0 comments on commit 565d48a

Please sign in to comment.
You can’t perform that action at this time.