Tue, 16 Feb 2016 16:28:44 +0200
Use a better gcd algorithm, some style fixes
src/dialogs/ldrawpathdialog.cpp | file | annotate | diff | comparison | revisions | |
src/miscallenous.cpp | file | annotate | diff | comparison | revisions |
--- a/src/dialogs/ldrawpathdialog.cpp Tue Feb 16 02:11:33 2016 +0200 +++ b/src/dialogs/ldrawpathdialog.cpp Tue Feb 16 16:28:44 2016 +0200 @@ -85,8 +85,10 @@ { okButton()->setEnabled (ok); - if (statusText.isEmpty() && ok == false) + if (statusText.isEmpty() and not ok) + { ui.status->setText ("---"); + } else { ui.status->setText (QString ("<span style=\"color: %1\">%2</span>")
--- a/src/miscallenous.cpp Tue Feb 16 02:11:33 2016 +0200 +++ b/src/miscallenous.cpp Tue Feb 16 16:28:44 2016 +0200 @@ -94,26 +94,22 @@ int gcd (int a, int b) { - if (a > 0 and b > 0) + while (b != 0) { - while (a != b) - { - if (a < b) - b -= a; - else - a -= b; - } + int temp = a; + a = b; + b = temp % b; } return a; } -void simplify (int& numer, int& denom) +void simplify (int& numerator, int& denominator) { - int factor = gcd (numer, denom); - numer /= factor; - denom /= factor; + int factor = gcd(numerator, denominator); + numerator /= factor; + denominator /= factor; }