Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't do expensive setup for sort if not needed
  • Loading branch information
lizmat committed Aug 1, 2014
1 parent b8e660f commit fb05219
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/List.pm
Expand Up @@ -395,8 +395,12 @@ my class List does Positional { # declared in BOOTSTRAP
# indices from 0..^$list.elems, then use that Parcel as
# a slice into self.

# nothing to do here
my $elems := self.elems;
return self if $elems < 2;

# Range is currently optimized for fast Parcel construction.
my $index := Range.new(0, self.elems, :excludes_max).reify(*);
my $index := Range.new(0, $elems, :excludes_max).reify(*);
my Mu $index_rpa := nqp::getattr($index, Parcel, '$!storage');

# if $by.arity < 2, then we apply the block to the elements
Expand Down

0 comments on commit fb05219

Please sign in to comment.