Skip to content

Commit

Permalink
Use native ints for Match $!to/$!from.
Browse files Browse the repository at this point in the history
This will certainly save a good amount of memory, but it also saves the
MATCH method from having to do two object boxings too. Of course, we do
them later in some cases, but I suspect this will be an overall win.
  • Loading branch information
jnthn committed Oct 10, 2012
1 parent 584f19e commit fb0b115
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/core/Cursor.pm
Expand Up @@ -9,8 +9,8 @@ my class Cursor does NQPCursorRole {
return $match if nqp::istype($match, Match) && nqp::isconcrete($match);
$match := nqp::create(Match);
nqp::bindattr($match, Match, '$!orig', nqp::getattr(self, Cursor, '$!orig'));
nqp::bindattr($match, Match, '$!from', nqp::p6box_i(nqp::getattr_i(self, Cursor, '$!from')));
nqp::bindattr($match, Match, '$!to', nqp::p6box_i(nqp::getattr_i(self, Cursor, '$!pos')));
nqp::bindattr_i($match, Match, '$!from', nqp::getattr_i(self, Cursor, '$!from'));
nqp::bindattr_i($match, Match, '$!to', nqp::getattr_i(self, Cursor, '$!pos'));
nqp::bindattr($match, Match, '$!ast', nqp::getattr(self, Cursor, '$!ast'));
nqp::bindattr($match, Match, '$!CURSOR', self);
my Mu $list := nqp::list();
Expand All @@ -23,7 +23,7 @@ my class Cursor does NQPCursorRole {
my str $key = $pair.key;
my Mu $value := $pair.value;
if $key eq '$!from' || $key eq '$!to' {
nqp::bindattr($match, Match, $key, nqp::p6box_i($value.from));
nqp::bindattr_i($match, Match, $key, $value.from);
}
else {
$value := nqp::p6list($value, List, Mu)
Expand Down
4 changes: 2 additions & 2 deletions src/core/Match.pm
@@ -1,7 +1,7 @@
my class Match is Capture is Cool {
has $.orig;
has $.from;
has $.to;
has int $.from;
has int $.to;
has $.CURSOR;
has $.ast;

Expand Down

0 comments on commit fb0b115

Please sign in to comment.