Skip to content

Commit

Permalink
Add Bool:D candidates for infix:<xx>
Browse files Browse the repository at this point in the history
- makes 42 xx False about 16x faster
- makes 42 xx True about 10% faster
  • Loading branch information
lizmat committed Jan 9, 2018
1 parent 5f7fdfd commit ca4fcac
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/List.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,9 @@ multi sub infix:<xx>(&x, Num:D() $n) {
multi sub infix:<xx>(&x, Whatever) {
Seq.new(Rakudo::Iterator.Callable-xx-Whatever(&x))
}
multi sub infix:<xx>(&x, Bool:D $b) {
$b ?? infix:<xx>(&x, 1) !! EmptySeq
}
multi sub infix:<xx>(&x, Int:D $n) {
my int $todo = $n + 1;
my Mu $pulled;
Expand Down Expand Up @@ -1584,6 +1587,9 @@ multi sub infix:<xx>(Mu \x, Num:D() $n) {
multi sub infix:<xx>(Mu \x, Whatever) {
Seq.new(Rakudo::Iterator.UnendingValue(x))
}
multi sub infix:<xx>(Mu \x, Bool:D $b) {
$b ?? Seq.new(Rakudo::Iterator.OneValue(x)) !! EmptySeq
}
multi sub infix:<xx>(Mu \x, Int:D $n) is pure {
Seq.new(Rakudo::Iterator.OneValueTimes(x,$n))
}
Expand Down

0 comments on commit ca4fcac

Please sign in to comment.