@@ -940,43 +940,40 @@ struct Factorizer {
940940 auto jkit = ikit;
941941 auto jvit = ivit;
942942
943- for (size_t j = i + 1U ; j < this ->smoothNumberKeys .size (); ++j) {
944- ++jkit;
945- ++jvit;
946-
947- if ((*ivit) != (*jvit)) {
948- continue ;
949- }
950-
951- // Compute x and y
952- const BigInteger x = ((*ikit) * (*jkit)) % this ->toFactor ;
953- const BigInteger y = modExp (x, this ->toFactor / 2 , this ->toFactor );
954-
955- // Check congruence of squares
956- BigInteger factor = gcd (this ->toFactor , x + y);
957- if ((factor != 1U ) && (factor != this ->toFactor )) {
958- std::lock_guard<std::mutex> lock (this ->batchMutex );
959- result = factor;
943+ for (size_t j = i; j < this ->smoothNumberKeys .size (); ++j) {
944+ if ((*ivit) == (*jvit)) {
945+ // Compute x and y
946+ const BigInteger x = ((*ikit) * (*jkit)) % this ->toFactor ;
947+ const BigInteger y = modExp (x, this ->toFactor / 2 , this ->toFactor );
948+
949+ // Check congruence of squares
950+ BigInteger factor = gcd (this ->toFactor , x + y);
951+ if ((factor != 1U ) && (factor != this ->toFactor )) {
952+ std::lock_guard<std::mutex> lock (this ->batchMutex );
953+ result = factor;
954+
955+ return true ;
956+ }
960957
961- return true ;
962- }
958+ if (x != y) {
959+ // Try x - y as well
960+ factor = gcd (this ->toFactor , x - y);
961+ if ((factor != 1U ) && (factor != this ->toFactor )) {
962+ std::lock_guard<std::mutex> lock (this ->batchMutex );
963+ result = factor;
963964
964- if (x == y) {
965- continue ;
965+ return true ;
966+ }
967+ }
966968 }
967969
968- // Try x - y as well
969- factor = gcd (this ->toFactor , x - y);
970- if ((factor != 1U ) && (factor != this ->toFactor )) {
971- std::lock_guard<std::mutex> lock (this ->batchMutex );
972- result = factor;
973-
974- return true ;
975- }
970+ ++jkit;
971+ ++jvit;
976972 }
977973
978974 return false ;
979975 });
976+
980977 ++ikit;
981978 ++ivit;
982979 }
0 commit comments