Skip to content

Commit

Permalink
Make Hash initialization about 10% faster
Browse files Browse the repository at this point in the history
By given Hash its own dedicated STORE_AT_KEY, since we spent much
more time initializing Hashes then we do Maps.
  • Loading branch information
lizmat committed Jul 3, 2016
1 parent 3fda0b0 commit ba09318
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/Hash.pm
Expand Up @@ -71,9 +71,19 @@ my class Hash { # declared in BOOTSTRAP
)
}

method STORE_AT_KEY(\key, Mu \x --> Nil) {
nqp::findmethod(Map,'STORE_AT_KEY')(self,key,
nqp::p6scalarfromdesc($!descriptor) = x)
multi method STORE_AT_KEY(Str:D \key, Mu \x --> Nil) {
nqp::bindkey(
nqp::getattr(self,Map,'$!storage'),
nqp::unbox_s(key),
(nqp::p6scalarfromdesc($!descriptor) = x),
)
}
multi method STORE_AT_KEY(\key, Mu \x --> Nil) {
nqp::bindkey(
nqp::getattr(self,Map,'$!storage'),
nqp::unbox_s(key.Str),
(nqp::p6scalarfromdesc($!descriptor) = x),
)
}

multi method ASSIGN-KEY(Hash:D: Str:D \key, Mu \assignval) is raw {
Expand Down

0 comments on commit ba09318

Please sign in to comment.