Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created March 22, 2017 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/17b8c6ba35ba145c59ae71a766a3c738 to your computer and use it in GitHub Desktop.
Save zoffixznet/17b8c6ba35ba145c59ae71a766a3c738 to your computer and use it in GitHub Desktop.
cpan@perlbuild2~/CPANPRC/rakudo (nom)$ gd
diff --git a/src/core/Any-iterable-methods.pm b/src/core/Any-iterable-methods.pm
index 8cd9ef6..9debcb4 100644
--- a/src/core/Any-iterable-methods.pm
+++ b/src/core/Any-iterable-methods.pm
@@ -762,13 +762,13 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
}
}
- sub sequential-map(\source, &block, $label) {
+ sub sequential-map(\source, &block, $label, $inner-block-has-phasers = Any) {
# We want map to be fast, so we go to some effort to build special
# case iterators that can ignore various interesting cases.
my $count = &block.count;
Seq.new(
- nqp::istype(&block,Block) && &block.has-phasers
+ nqp::istype(&block,Block) && ($inner-block-has-phasers || &block.has-phasers)
?? $count < 2 || $count === Inf
?? IterateOneWithPhasers.new(&block,source,$label)
!! IterateMoreWithPhasers.new(&block,source,$count,$label)
@@ -911,27 +911,29 @@ Did you mean to add a stub (\{...\}) or did you mean to .classify?"
sequential-map(
self.iterator,
{ nqp::if($test($_),$_,Empty) },
- Any)
+ Any, $test.?has-phasers)
,
nqp::stmts(
- (my role CheatArity {
+ (my role CheatArityAndPhasers {
has $!arity;
has $!count;
+ has $!has-phasers;
- method set-cheat($new-arity, $new-count --> Nil) {
- $!arity = $new-arity;
- $!count = $new-count;
+ method set-cheat($new-arity, $new-count, $has-phasers --> Nil) {
+ $!arity = $new-arity;
+ $!count = $new-count;
+ $!has-phasers = $has-phasers;
}
- method arity(Code:D:) { $!arity }
- method count(Code:D:) { $!count }
+ method arity(Code:D:) { $!arity }
+ method count(Code:D:) { $!count }
+ method has-phasers(Code:D:) { $!has-phasers }
}),
(my &tester = -> |c {
- #note "*cough* {c.perl} -> {$test(|c).perl}";
next unless $test(|c);
c.list
- } but CheatArity),
- &tester.set-cheat($test.arity, $test.count),
+ } but CheatArityAndPhasers),
+ &tester.set-cheat($test.arity, $test.count, $test.?has-phasers),
self.map(&tester)
)
)
cpan@perlbuild2~/CPANPRC/rakudo (nom)$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment