Skip to content
Permalink
Browse files

Make Rational `===` Rational 2.47x as fast

We now normalize all the Rationals, so we can simplify things
  • Loading branch information...
zoffixznet committed Sep 24, 2018
1 parent c5a2eb8 commit 97e8413b4fd542576aa1bc83c20f6b40bab1b7f4
Showing with 4 additions and 7 deletions.
  1. +4 −7 src/core/Rat.pm6
@@ -233,13 +233,10 @@ multi sub infix:<==>(Int:D \a, Rational:D \b) {
nqp::iseq_I(nqp::decont(a), b.numerator) && nqp::iseq_I(b.denominator, 1))
}
multi sub infix:<===>(Rational:D \a, Rational:D \b --> Bool:D) {
# Check whether we have 0-denominator rationals as well. Those can
# be `==` but have different numerator values and so should not `===` True.
# Since we're already checking equality first, we only need to check the
# zeroeness of the denominator of just one parameter
a.WHAT =:= b.WHAT
&& (a == b || (a.isNaN && b.isNaN))
&& (a.denominator.Bool || a.numerator == b.numerator)
nqp::hllbool(
nqp::eqaddr(a.WHAT, b.WHAT)
&& nqp::iseq_I(a.numerator, b.numerator)
&& nqp::iseq_I(a.denominator, b.denominator))
}

multi sub infix:«<»(Rational:D \a, Rational:D \b) {

0 comments on commit 97e8413

Please sign in to comment.
You can’t perform that action at this time.