Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created June 15, 2017 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizmat/f8978bee4ec54232702d06bddcf50efa to your computer and use it in GitHub Desktop.
Save lizmat/f8978bee4ec54232702d06bddcf50efa to your computer and use it in GitHub Desktop.
potential DYNAMIC speedup
diff --git a/src/core/stubs.pm b/src/core/stubs.pm
index 5e58739..5eb0db9 100644
--- a/src/core/stubs.pm
+++ b/src/core/stubs.pm
@@ -29,25 +29,27 @@ my class Lock is repr('ReentrantMutex') { ... }
sub DYNAMIC(\name) is raw {
nqp::ifnull(
- nqp::getlexdyn(nqp::unbox_s(name)),
+ nqp::getlexdyn(name),
nqp::stmts(
nqp::unless(
nqp::isnull(my $prom := nqp::getlexdyn('$*PROMISE')),
(my Mu $x := nqp::getlexreldyn(
- nqp::getattr($prom,Promise,'$!dynamic_context'),nqp::unbox_s(name))
+ nqp::getattr($prom,Promise,'$!dynamic_context'),name)
)
),
- nqp::if(
- nqp::isnull($x),
+ nqp::ifnull(
+ $x,
nqp::stmts(
- (my str $pkgname = nqp::replace(nqp::unbox_s(name),1,1,'')),
- ($x := nqp::ifnull(nqp::atkey(GLOBAL.WHO,$pkgname),
- nqp::ifnull(nqp::atkey(PROCESS.WHO,$pkgname),
- Rakudo::Internals.INITIALIZE-DYNAMIC(nqp::unbox_s(name))))
+ (my str $pkgname = nqp::replace(name,1,1,'')),
+ nqp::ifnull(
+ nqp::atkey(GLOBAL.WHO,$pkgname),
+ nqp::ifnull(
+ nqp::atkey(PROCESS.WHO,$pkgname),
+ Rakudo::Internals.INITIALIZE-DYNAMIC(name)
+ )
)
)
- ),
- $x
+ )
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment