Skip to content

Commit

Permalink
Add two special cases for infix:<,>
Browse files Browse the repository at this point in the history
Since these are likely to be common cases, give them a fast path.
  • Loading branch information
MasterDuke17 committed Mar 10, 2018
1 parent 65874b1 commit b6e5d7f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/List.pm6
Expand Up @@ -1492,6 +1492,12 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
# The , operator produces a List.
proto sub infix:<,>(|) is pure {*}
multi sub infix:<,>() { nqp::create(List) }
multi sub infix:<,>(Int \a, Int \b) is default {
nqp::p6bindattrinvres(nqp::create(List),List,'$!reified',nqp::list(a,b))
}
multi sub infix:<,>(Str \a, Str \b) {
nqp::p6bindattrinvres(nqp::create(List),List,'$!reified',nqp::list(a,b))
}
multi sub infix:<,>(|) {

# look for a Slip in the parameters
Expand Down

3 comments on commit b6e5d7f

@lizmat
Copy link
Contributor

@lizmat lizmat commented on b6e5d7f Mar 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a single:

multi sub infix:<,>(Cool \a, Cool \b) {
    nqp::p6bindattrinvres(nqp::create(List),List,'$!reified',nqp::list(a,b))
}

? Or even a single:

multi sub infix:<,>(Any \a, Any \b) {
    nqp::p6bindattrinvres(nqp::create(List),List,'$!reified',nqp::list(a,b))
}

?

@zoffixznet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of those would need to handle a Slip and looks like that was attempted, but it made Slip case a lot slower.

@zoffixznet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tho looking at that attempt, I'd guess it's the use of nextsame that makes it slow. It might be worth trying to extract the Slip handling case into a Rakudo::Internals sub and calling that instead of nextsame

Please sign in to comment.