Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Streamline @A[*-1]:adverb by about 25%
  • Loading branch information
lizmat committed Jan 15, 2015
1 parent 4853cce commit 0463a4b
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/core/array_slice.pm
Expand Up @@ -174,40 +174,40 @@ multi sub postcircumfix:<[ ]>(\SELF, Callable:D $block, :$SINK!, *%other) is rw
SLICE_MORE( SELF, POSITIONS(SELF,$block), True, :$SINK, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF,Callable:D $block,:$delete!,*%other) is rw {
my @positions := POSITIONS(SELF,$block);
@positions.elems == 1
?? SLICE_ONE( SELF, @positions[0], True, :$delete, |%other )
!! SLICE_MORE( SELF, @positions, True, :$delete, |%other );
my $pos := $block(|(SELF.elems xx $block.count));
nqp::istype($pos,Int)
?? SLICE_ONE( SELF, $pos, True, :$delete, |%other )
!! SLICE_MORE( SELF, @$pos, True, :$delete, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF,Callable:D $block,:$exists!,*%other) is rw {
my @positions := POSITIONS(SELF,$block);
@positions.elems == 1
?? SLICE_ONE( SELF, @positions[0], True, :$exists, |%other )
!! SLICE_MORE( SELF, @positions, True, :$exists, |%other );
my $pos := $block(|(SELF.elems xx $block.count));
nqp::istype($pos,Int)
?? SLICE_ONE( SELF, $pos, True, :$exists, |%other )
!! SLICE_MORE( SELF, @$pos, True, :$exists, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF, Callable:D $block, :$kv!, *%other) is rw {
my @positions := POSITIONS(SELF,$block);
@positions.elems == 1
?? SLICE_ONE( SELF, @positions[0], True, :$kv, |%other )
!! SLICE_MORE( SELF, @positions, True, :$kv, |%other );
my $pos := $block(|(SELF.elems xx $block.count));
nqp::istype($pos,Int)
?? SLICE_ONE( SELF, $pos, True, :$kv, |%other )
!! SLICE_MORE( SELF, @$pos, True, :$kv, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF, Callable:D $block, :$p!, *%other) is rw {
my @positions := POSITIONS(SELF,$block);
@positions.elems == 1
?? SLICE_ONE( SELF, @positions[0], True, :$p, |%other )
!! SLICE_MORE( SELF, @positions, True, :$p, |%other );
my $pos := $block(|(SELF.elems xx $block.count));
nqp::istype($pos,Int)
?? SLICE_ONE( SELF, $pos, True, :$p, |%other )
!! SLICE_MORE( SELF, @$pos, True, :$p, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF, Callable:D $block, :$k!, *%other) is rw {
my @positions := POSITIONS(SELF,$block);
@positions.elems == 1
?? SLICE_ONE( SELF, @positions[0], True, :$k, |%other )
!! SLICE_MORE( SELF, @positions, True, :$k, |%other );
my $pos := $block(|(SELF.elems xx $block.count));
nqp::istype($pos,Int)
?? SLICE_ONE( SELF, $pos, True, :$k, |%other )
!! SLICE_MORE( SELF, @$pos, True, :$k, |%other );
}
multi sub postcircumfix:<[ ]>(\SELF, Callable:D $block, :$v!, *%other) is rw {
my @positions := POSITIONS(SELF,$block);
@positions.elems == 1
?? SLICE_ONE( SELF, @positions[0], True, :$v, |%other )
!! SLICE_MORE( SELF, @positions, True, :$v, |%other );
my $pos := $block(|(SELF.elems xx $block.count));
nqp::istype($pos,Int)
?? SLICE_ONE( SELF, $pos, True, :$v, |%other )
!! SLICE_MORE( SELF, @$pos, True, :$v, |%other );
}

# @a[*]
Expand Down

0 comments on commit 0463a4b

Please sign in to comment.