Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid a load of hash allocation/copies.
Normally we just set symbol properties once ever, so just use the
slurpy hash we already have rather than creating a new one and copying
to it. Saves a ton of hash and hash iterator allocations.

This makes `for ^500 { EVAL 'regex { abcdef }' }` in Perl 6 run in
about 85% of the time it used to (and will similarly help other EVAL
heavy things, and shave a bit off compile times generally).
  • Loading branch information
jnthn committed Mar 9, 2016
1 parent deb4ce6 commit 78db547
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/QAST/Block.nqp
Expand Up @@ -60,11 +60,13 @@ class QAST::Block is QAST::Node does QAST::Children {
%!symbol := nqp::hash() if nqp::isnull(%!symbol);
if %attrs {
my %syms := %!symbol{$name};
unless nqp::ishash(%syms) {
%!symbol{$name} := %syms := nqp::hash();
if nqp::ishash(%syms) && nqp::elems(%syms) {
for %attrs {
%syms{$_.key} := $_.value;
}
}
for %attrs {
%syms{$_.key} := $_.value;
else {
%!symbol{$name} := %syms := %attrs;
}
%syms
}
Expand Down

0 comments on commit 78db547

Please sign in to comment.