Permalink
Browse files

LANG passes on target and orig.

This avoids re-transcoding every single time we switch language, and
fixes the memory use regression in rakudo/Q.
  • Loading branch information...
1 parent c077b22 commit acae25d275486ca0b428d779a4c0f1ea82e480c1 @jnthn jnthn committed Oct 31, 2012
Showing with 6 additions and 5 deletions.
  1. +1 −1 src/HLL/Grammar.pm
  2. +5 −4 src/QRegex/Cursor.nqp
View
@@ -784,7 +784,7 @@ An operator precedence parser.
}
method LANG($lang, $regex, *@args) {
- my $lang_cursor := %*LANG{$lang}.'!cursor_init'(self.orig(), :p(self.pos()));
+ my $lang_cursor := %*LANG{$lang}.'!cursor_init'(self.orig(), :p(self.pos()), :target(self.target()));
if self.HOW.traced(self) {
$lang_cursor.HOW.trace-on($lang_cursor, self.HOW.trace_depth(self));
}
View
@@ -65,11 +65,12 @@ role NQPCursorRole is export {
$caps;
}
- method !cursor_init($target, :$p = 0, :$c) {
+ method !cursor_init($orig, :$p = 0, :$c, :$target) {
my $new := self.CREATE();
- nqp::bindattr($new, $?CLASS, '$!orig', $target);
- $target := pir::trans_encoding__Ssi($target, pir::find_encoding__Is('ucs4'));
- nqp::bindattr_s($new, $?CLASS, '$!target', $target);
+ nqp::bindattr($new, $?CLASS, '$!orig', $orig);
+ nqp::bindattr_s($new, $?CLASS, '$!target', $target
+ ?? $target
+ !! pir::trans_encoding__Ssi($orig, pir::find_encoding__Is('ucs4')));
if nqp::defined($c) {
nqp::bindattr_i($new, $?CLASS, '$!from', -1);
nqp::bindattr_i($new, $?CLASS, '$!pos', $c);

0 comments on commit acae25d

Please sign in to comment.