Commit 139fa202 authored by Abseil Team's avatar Abseil Team Committed by Mark Barolak
Browse files

Googletest export

Refactor function GetNextPrime so that the loop precondition is checked before
loop instead of during every loop run.  Also by removing the loop condition,
it shows that the only exit from the loop is the return statement.

PiperOrigin-RevId: 293932783
parent 41b5f149
...@@ -66,11 +66,11 @@ class OnTheFlyPrimeTable : public PrimeTable { ...@@ -66,11 +66,11 @@ class OnTheFlyPrimeTable : public PrimeTable {
} }
int GetNextPrime(int p) const override { int GetNextPrime(int p) const override {
for (int n = p + 1; n > 0; n++) { if (p < 0) return -1;
for (int n = p + 1;; n++) {
if (IsPrime(n)) return n; if (IsPrime(n)) return n;
} }
return -1;
} }
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment