Skip to content

Commit

Permalink
Put the new Zop handling live for 13x improvement
Browse files Browse the repository at this point in the history
- except for thunky.starts-with('.') ops
  these are lazy in the fetching of values from the iterators in a
  way that I haven't fully grokked, so we're using the old code for
  those cases.  This includes: Zand, Z&&, Zor, Z||, Zxor, Z^^
  • Loading branch information
lizmat committed Jan 10, 2017
1 parent 8654389 commit f66d4b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/core/List.pm
Expand Up @@ -1595,14 +1595,14 @@ my &cross := &infix:<X>;

proto sub infix:<Z>(|) is pure {*}
multi sub infix:<Z>(+lol, :&with!) {
nqp::if(
Seq.new(nqp::if(
nqp::eqaddr(&with,&infix:<,>),
Seq.new(Rakudo::Internals.ZipIterablesIterator(lol)),
Seq.new(Rakudo::Internals.ZipIterablesMapIterator(
Rakudo::Internals.ZipIterablesIterator(lol),
Rakudo::Internals.ZipIterablesMapIterator(
lol,
Rakudo::Metaops.MapperForOp(&with)
))
)
)
))
}
multi sub infix:<Z>(+lol) {
Seq.new(Rakudo::Internals.ZipIterablesIterator(lol))
Expand Down
14 changes: 13 additions & 1 deletion src/core/metaops.pm
Expand Up @@ -75,6 +75,7 @@ sub METAOP_CROSS(\op, &reduce) {
}

sub METAOP_ZIP(\op, &reduce) {
nqp::if(op.prec('thunky').starts-with('.'),
-> +lol {
my $arity = lol.elems;
my $rop = $arity == 2 ?? op !! &reduce(op);
Expand All @@ -101,8 +102,19 @@ sub METAOP_ZIP(\op, &reduce) {
last if $z.elems < $arity;
take-rw $arity == 2 ?? $rop(|$z) !! $rop(@$z);
}
}.lazy-if($laze);
}.lazy-if($laze)
},
-> +lol {
Seq.new(nqp::if(
nqp::eqaddr(op,&infix:<,>),
Rakudo::Internals.ZipIterablesIterator(lol),
Rakudo::Internals.ZipIterablesMapIterator(
lol,
Rakudo::Metaops.MapperForOp(op)
)
))
}
)
}

proto sub METAOP_REDUCE_LEFT(|) { * }
Expand Down

0 comments on commit f66d4b3

Please sign in to comment.