Skip to content

Instantly share code, notes, and snippets.

@timo
Created July 6, 2013 11:50
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 timo/91483e54fa0b20173f5f to your computer and use it in GitHub Desktop.
Save timo/91483e54fa0b20173f5f to your computer and use it in GitHub Desktop.
does this seem like a sane optimisation?
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