Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid copying all of the lhs into @args #5

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/core/operators.pm
Expand Up @@ -377,13 +377,11 @@ our sub _HELPER_generate-series(@lhs, $rhs , :$exclude-limit) {
gather {
my $i = 0;
while @lhs[$i+1].defined { take @lhs[$i]; $i++; } #We blindly take all elems of the LHS except last one.
take @lhs[$i] unless @lhs[$i] ~~ Code; #We don't take the last element if it is code because it will be used as $next closure
if @lhs[$i] !~~ Code { take @lhs[$i]; $i++; } #We take the last element only when it is not code

my $next = get-next-closure(@lhs , $limit );
my $arity = $next.count;
my @args=@lhs; #TODO: maybe avoid copying the whole array into args
pop @args if @args[*-1] ~~ Code;
@args.munch( @args.elems - $arity ); #We make sure there are $arity elems in args
my @args=@lhs[$i-($arity ~~ Inf ?? $i !! $arity) .. $i-1]; #We make sure there are $arity elems in args

loop { #Then we extrapolate using $next and the $args
my $current = $next.(|@args) // last;
Expand Down