Skip to content

Commit

Permalink
Optimize QAST node creation.
Browse files Browse the repository at this point in the history
Worth it since it's a very hot path.
  • Loading branch information
jnthn committed Dec 4, 2013
1 parent d77348a commit 647351b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/QAST/Node.nqp
Expand Up @@ -9,11 +9,14 @@ class QAST::Node {
has $!returns;

method new(*@children, *%options) {
my $new := self.CREATE();
my $new := nqp::create(self);
nqp::bindattr($new, QAST::Node, '@!array', @children);
nqp::bindattr($new, QAST::Node, '%!hash', nqp::hash());
for %options {
nqp::findmethod($new, $_.key)($new, $_.value);
my $it := nqp::iterator(%options);
my $cur;
while $it {
$cur := nqp::shift($it);
nqp::findmethod($new, nqp::iterkey_s($cur))($new, nqp::iterval($cur))
}
$new;
}
Expand Down

0 comments on commit 647351b

Please sign in to comment.