Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
avoid creating some scalars in capture methods
  • Loading branch information
timo committed Nov 4, 2014
1 parent 8a4b9e8 commit 32959f6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/Capture.pm
Expand Up @@ -26,19 +26,29 @@ my class Capture { # declared in BOOTSTRAP
$WHICH;
}

method at_key(Capture:D: $key is copy) {
multi method at_key(Capture:D: $key is copy) {
$key = $key.Str;
nqp::existskey($!hash, nqp::unbox_s($key))
?? nqp::atkey($!hash, nqp::unbox_s($key))
!! Any
}
multi method at_key(Capture:D: Str $key) {
nqp::existskey($!hash, nqp::unbox_s($key))
?? nqp::atkey($!hash, nqp::unbox_s($key))
!! Any
}

method at_pos(Capture:D: $pos is copy) {
multi method at_pos(Capture:D: $pos is copy) {
$pos = $pos.Int;
nqp::existspos($!list, nqp::unbox_i($pos))
?? nqp::atpos($!list, nqp::unbox_i($pos))
!! Any
}
multi method at_pos(Capture:D: Int $pos) {
nqp::existspos($!list, nqp::unbox_i($pos))
?? nqp::atpos($!list, nqp::unbox_i($pos))
!! Any
}

method hash(Capture:D:) {
my $enum := nqp::create(EnumMap);
Expand Down

0 comments on commit 32959f6

Please sign in to comment.