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
This commit is contained in:
Abseil Team 2020-02-07 20:54:07 -05:00 committed by Mark Barolak
parent 41b5f149ab
commit 139fa202c9

View File

@ -66,11 +66,11 @@ class OnTheFlyPrimeTable : public PrimeTable {
}
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;
}
return -1;
}
};