Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Small optimizations to .symbol.
  • Loading branch information
jnthn committed Aug 1, 2014
1 parent b733404 commit aa8a615
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/QAST/Block.nqp
Expand Up @@ -40,15 +40,22 @@ class QAST::Block is QAST::Node {
}
}

my %NOSYMS := nqp::hash();
method symbol($name, *%attrs) {
%!symbol := nqp::hash() if nqp::isnull(%!symbol);
if %attrs {
%!symbol{$name} := %!symbol{$name} // {};
my %syms := %!symbol{$name};
unless nqp::ishash(%syms) {
%!symbol{$name} := %syms := nqp::hash();
}
for %attrs {
%!symbol{$name}{$_.key} := $_.value;
%syms{$_.key} := $_.value;
}
%syms
}
else {
nqp::ifnull(nqp::atkey(%!symbol, $name), %NOSYMS)
}
%!symbol{$name}
}

method symtable() {
Expand Down

0 comments on commit aa8a615

Please sign in to comment.