Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make Parcel.rotate not die on empty Parcels
And make it not do anything when it doesn't need to do anything
  • Loading branch information
lizmat committed Oct 21, 2014
1 parent 5054419 commit 8102da0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/Parcel.pm
Expand Up @@ -54,8 +54,13 @@ my class Parcel does Positional { # declared in BOOTSTRAP
}

method rotate (Int $n is copy = 1) {
my $elems := nqp::p6box_i(nqp::elems($!storage));
return self if !$elems;

$n %= $elems;
return self if $n == 0;

my Mu $storage := nqp::clone($!storage);
$n %= nqp::p6box_i(nqp::elems($!storage));
if $n > 0 {
nqp::push($storage, nqp::shift($storage)) while $n--;
}
Expand Down

0 comments on commit 8102da0

Please sign in to comment.