Skip to content

Commit 6528f59

Browse files
Fix exit condition after G.E.
1 parent 6a47bfd commit 6528f59

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

FindAFactor/_find_a_factor.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ struct Factorizer {
944944
auto ivit = smoothNumberValues.begin();
945945
BigInteger result = 1U;
946946
batchMutex.lock();
947-
for (size_t i = 0U; i < smoothNumberKeys.size(); ++i) {
947+
for (size_t i = 0U; isIncomplete && (i < smoothNumberKeys.size()); ++i) {
948948
dispatch.dispatch([this, i, ikit, ivit, &result]() -> bool {
949949
auto jkit = ikit;
950950
auto jvit = ivit;
@@ -989,7 +989,7 @@ struct Factorizer {
989989
return false;
990990
});
991991

992-
// If we all still dispatching items in the queue,
992+
// If we are still dispatching items in the queue,
993993
// they probably won't have completed, but let
994994
// them take a turn with the mutex.
995995
batchMutex.unlock();
@@ -1000,9 +1000,6 @@ struct Factorizer {
10001000

10011001
// If this actually contends, we'll exit now.
10021002
batchMutex.lock();
1003-
if (!isIncomplete) {
1004-
break;
1005-
}
10061003
}
10071004

10081005
if (result == 1U) {

0 commit comments

Comments
 (0)