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:
parent
41b5f149ab
commit
139fa202c9
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user