Skip to content

Commit

Permalink
Make infix:<≤> an alias of infix:«<=»
Browse files Browse the repository at this point in the history
By making it an alias, we can get rid of all of the duplication for the
unicode operator.  This reduces memory size (about 10K in the setting.moarvm)
and maintenance burden (because additional candidates will only need to be
added for the ascii version of the operator).

Please note that the alias *must* use <> brackets: apparently creating
constants takes literal names, and 'sub infix:«≤»; normalizes to <> brackets.
  • Loading branch information
lizmat committed Mar 1, 2018
1 parent f5b23a5 commit aadd3c1
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 35 deletions.
3 changes: 0 additions & 3 deletions src/core/Date.pm
Expand Up @@ -199,9 +199,6 @@ multi sub infix:<==>(Date:D $a, Date:D $b) {
multi sub infix<=»(Date:D $a, Date:D $b) {
$a.daycount <= $b.daycount
}
multi sub infix:«≤»(Date:D $a, Date:D $b) {
$a.daycount ≤ $b.daycount
}
multi sub infix<»(Date:D $a, Date:D $b) {
$a.daycount < $b.daycount
}
Expand Down
3 changes: 0 additions & 3 deletions src/core/DateTime.pm
Expand Up @@ -405,9 +405,6 @@ multi sub infix:«>»(DateTime:D \a, DateTime:D \b) {
multi sub infix<=»(DateTime:D \a, DateTime:D \b) {
a.Instant <= b.Instant
}
multi sub infix:«≤»(DateTime:D \a, DateTime:D \b) {
a.Instant ≤ b.Instant
}
multi sub infix>=»(DateTime:D \a, DateTime:D \b) {
a.Instant >= b.Instant
}
Expand Down
3 changes: 0 additions & 3 deletions src/core/Instant.pm
Expand Up @@ -86,9 +86,6 @@ multi sub infix:«>»(Instant:D $a, Instant:D $b) {
multi sub infix<=»(Instant:D $a, Instant:D $b) {
$a.tai <= $b.tai
}
multi sub infix:«≤»(Instant:D $a, Instant:D $b) {
$a.tai ≤ $b.tai
}

multi sub infix>=»(Instant:D $a, Instant:D $b) {
$a.tai >= $b.tai
Expand Down
6 changes: 0 additions & 6 deletions src/core/Int.pm
Expand Up @@ -368,12 +368,6 @@ multi sub infix:«<=»(Int:D \a, Int:D \b) {
multi sub infix<=»(int $a, int $b) {
nqp::p6bool(nqp::isle_i($a, $b))
}
multi sub infix:«≤»(Int:D \a, Int:D \b) {
nqp::p6bool(nqp::isle_I(nqp::decont(a), nqp::decont(b)))
}
multi sub infix:«≤»(int $a, int $b) {
nqp::p6bool(nqp::isle_i($a, $b))
}

multi sub infix>»(Int:D \a, Int:D \b) {
nqp::p6bool(nqp::isgt_I(nqp::decont(a), nqp::decont(b)))
Expand Down
6 changes: 0 additions & 6 deletions src/core/Num.pm
Expand Up @@ -490,12 +490,6 @@ multi sub infix:«<=»(Num:D \a, Num:D \b --> Bool:D) {
multi sub infix<=»(num $a, num $b --> Bool:D) {
nqp::p6bool(nqp::isle_n($a, $b))
}
multi sub infix:«≤»(Num:D \a, Num:D \b --> Bool:D) {
nqp::p6bool(nqp::isle_n(nqp::unbox_n(a), nqp::unbox_n(b)))
}
multi sub infix:«≤»(num $a, num $b --> Bool:D) {
nqp::p6bool(nqp::isle_n($a, $b))
}

multi sub infix>»(Num:D \a, Num:D \b --> Bool:D) {
nqp::p6bool(nqp::isgt_n(nqp::unbox_n(a), nqp::unbox_n(b)))
Expand Down
5 changes: 2 additions & 3 deletions src/core/Numeric.pm
Expand Up @@ -314,9 +314,8 @@ multi sub infix:«<»(\a, \b) { a.Real < b.Real }
proto sub infix<=»(Mu $?, Mu $?) is pure {*}
multi sub infix<=»($?) { Bool::True }
multi sub infix<=»(\a, \b) { a.Real <= b.Real }
proto sub infix:«≤» (Mu $?, Mu $?) is pure {*}
multi sub infix:«≤» ($?) { Bool::True }
multi sub infix:«≤» (\a, \b) { a.Real ≤ b.Real }
# U+2264 LESS-THAN OR EQUAL TO
my constant &infix:<> := &infix:«<=»;

proto sub infix>»(Mu $?, Mu $?) is pure {*}
multi sub infix>»($?) { Bool::True }
Expand Down
9 changes: 0 additions & 9 deletions src/core/Rat.pm
Expand Up @@ -254,15 +254,6 @@ multi sub infix:«<=»(Rational:D \a, Int:D \b) {
multi sub infix<=»(Int:D \a, Rational:D \b) {
a * b.denominator <= b.numerator
}
multi sub infix:«≤»(Rational:D \a, Rational:D \b) {
a.numerator * b.denominator ≤ b.numerator * a.denominator
}
multi sub infix:«≤»(Rational:D \a, Int:D \b) {
a.numerator ≤ b * a.denominator
}
multi sub infix:«≤»(Int:D \a, Rational:D \b) {
a * b.denominator ≤ b.numerator
}

multi sub infix>»(Rational:D \a, Rational:D \b) {
a.numerator * b.denominator > b.numerator * a.denominator
Expand Down
1 change: 0 additions & 1 deletion src/core/Real.pm
Expand Up @@ -153,7 +153,6 @@ multi sub infix:<==>(Real \a, Real \b) { a.Bridge == b.Bridge }
multi sub infix<»(Real \a, Real \b) { a.Bridge < b.Bridge }

multi sub infix<=»(Real \a, Real \b) { a.Bridge <= b.Bridge }
multi sub infix:«≤» (Real \a, Real \b) { a.Bridge ≤ b.Bridge }

multi sub infix>»(Real \a, Real \b) { a.Bridge > b.Bridge }

Expand Down
1 change: 0 additions & 1 deletion src/core/Version.pm
Expand Up @@ -209,7 +209,6 @@ multi sub infix:<cmp>(Version:D \a, Version:D \b) {
multi sub infix:«<=>»(Version:D \a, Version:D \b) { a cmp b }
multi sub infix<» (Version:D \a, Version:D \b) { a cmp b == Less }
multi sub infix<=» (Version:D \a, Version:D \b) { a cmp b != More }
multi sub infix:«≤» (Version:D \a, Version:D \b) { a cmp b != More }
multi sub infix==» (Version:D \a, Version:D \b) { a cmp b == Same }
multi sub infix!=» (Version:D \a, Version:D \b) { a cmp b != Same }
multi sub infix:«≠» (Version:D \a, Version:D \b) { a cmp b ≠ Same }
Expand Down

0 comments on commit aadd3c1

Please sign in to comment.