From: Keith OHara Date: Sun, 28 Dec 2014 05:39:55 +0000 (-0800) Subject: compare LilyPond Rationals without unnecessary overflow; issue 4180 X-Git-Tag: release/2.19.16-1~2^2~38^2~18 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=37756aa46375edb6b2f5af486297278da4358eb3;p=lilypond.git compare LilyPond Rationals without unnecessary overflow; issue 4180 This reverses part of commit 19125bf1, which said that (r-s).sign() was too expensive, but I saw no change (within 0.1%) in compilation times. --- diff --git a/flower/rational.cc b/flower/rational.cc index a6f82d826e..559e1646a0 100644 --- a/flower/rational.cc +++ b/flower/rational.cc @@ -216,11 +216,11 @@ Rational::compare (Rational const &r, Rational const &s) return -1; else if (r.sign_ > s.sign_) return 1; - else if (r.is_infinity ()) + else if (r.is_infinity ()) // here s is also infinite with the same sign return 0; - else if (r.sign_ == 0) + else if (r.sign_ == 0) // here s.sign_ is also zero return 0; - return r.sign_ * ::sign ((I64) (r.num_ * s.den_) - (I64) (s.num_ * r.den_)); + return ::sign (r - s); } int