Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prevent Num &infix:<cmp> from creating useless Bool
This is another commit following up on b2ae599.  This commit
replaces Num's use of &infix:<or>, which was needlessly constructing a
Bool.
  • Loading branch information
codesections committed Mar 6, 2021
1 parent 9ad4717 commit 7f2dba7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core.c/Num.pm6
Expand Up @@ -413,14 +413,14 @@ multi sub infix:<**>(num $a, num $b --> num) {

# Here we sort NaN in with string "NaN"
multi sub infix:<cmp>(Num:D \a, Num:D \b) {
ORDER(nqp::cmp_n(nqp::unbox_n(a), nqp::unbox_n(b))) or
a === b ?? Same # === cares about signed zeros, we don't, so:
nqp::cmp_n(nqp::unbox_n(a), nqp::unbox_n(b)) ?? ORDER(nqp::cmp_n(nqp::unbox_n(a), nqp::unbox_n(b)))
!! a === b ?? Same # === cares about signed zeros, we don't, so:
!! nqp::iseq_n(a, 0e0) && nqp::iseq_n(b, 0e0)
?? Same !! a.Stringy cmp b.Stringy;
}
multi sub infix:<cmp>(num $a, num $b) {
ORDER(nqp::cmp_n($a, $b)) or
$a === $b ?? Same # === cares about signed zeros, we don't, so:
nqp::cmp_n($a, $b) ?? ORDER(nqp::cmp_n($a, $b))
!! $a === $b ?? Same # === cares about signed zeros, we don't, so:
!! nqp::iseq_n($a, 0e0) && nqp::iseq_n($b, 0e0)
?? Same !! $a.Stringy cmp $b.Stringy;
}
Expand Down

0 comments on commit 7f2dba7

Please sign in to comment.