-
-
Save timo/91483e54fa0b20173f5f to your computer and use it in GitHub Desktop.
does this seem like a sane optimisation?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/List.pm b/src/core/List.pm | |
index 693597e..50268ae 100644 | |
--- a/src/core/List.pm | |
+++ b/src/core/List.pm | |
@@ -431,8 +431,20 @@ proto infix:<xx>(|) { * } | |
multi infix:<xx>() { fail "No zero-arg meaning for infix:<xx>" } | |
multi infix:<xx>(Mu \x) {x } | |
multi infix:<xx>(Mu \x, $n is copy, :$thunked) { | |
- $n = nqp::p6bool(nqp::istype($n, Whatever)) ?? $Inf !! $n.Int; | |
- GatherIter.new({ take ($thunked ?? x.() !! x) while $n-- > 0; }, :infinite($n == $Inf)).list | |
+ if nqp::istype($n, Whatever) { | |
+ if $thunked { | |
+ GatherIter.new({ take x.() while True; }, :infinite).list | |
+ } else { | |
+ GatherIter.new({ take x while True; }, :infinite).list | |
+ } | |
+ } else { | |
+ $n = $n.Int; | |
+ if $thunked { | |
+ GatherIter.new({ take x.() while $n-- > 0; }).list | |
+ } else { | |
+ GatherIter.new({ take x while $n-- > 0; }).list | |
+ } | |
+ } | |
} | |
proto sub pop(@) {*} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment