Permalink
Browse files

Use native ints for Match $!to/$!from.

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...
1 parent 584f19e commit fb0b1152051c8f2b555a5810cecb2678d72fa0c2 @jnthn jnthn committed Oct 10, 2012
Showing with 5 additions and 5 deletions.
  1. +3 −3 src/core/Cursor.pm
  2. +2 −2 src/core/Match.pm
View
6 src/core/Cursor.pm
@@ -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();
@@ -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)
View
4 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;

0 comments on commit fb0b115

Please sign in to comment.