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
pull/2706/head
Abseil Team 5 years ago committed by Mark Barolak
parent 41b5f149ab
commit 139fa202c9
  1. 6
      googletest/samples/prime_tables.h

@ -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…
Cancel
Save