Skip to content

Commit

Permalink
Further code shrinkage of Hash.ASSIGN-KEY
Browse files Browse the repository at this point in the history
To really make sure it's getting reliably inlined.
  • Loading branch information
jnthn committed Aug 9, 2018
1 parent 9a5c538 commit c60a347
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions src/core/Hash.pm6
Expand Up @@ -113,33 +113,23 @@ my class Hash { # declared in BOOTSTRAP
}

multi method ASSIGN-KEY(Hash:D: Str:D \key, Mu \assignval) is raw {
nqp::if(
nqp::isnull(
(my $target := nqp::atkey(nqp::getattr(self,Map,'$!storage'),key))
),
nqp::bindkey(
nqp::getattr(self,Map,'$!storage'),
key,
nqp::p6scalarwithvalue($!descriptor,assignval)
),
nqp::p6assign($target,assignval)
)
my \storage := nqp::getattr(self,Map,'$!storage');
nqp::p6assign(
nqp::ifnull(
nqp::atkey(storage, key),
nqp::bindkey(storage, key,
nqp::p6bindattrinvres(nqp::create(Scalar), Scalar, '$!descriptor', $!descriptor))),
assignval)
}
multi method ASSIGN-KEY(Hash:D: \key, Mu \assignval) is raw {
nqp::if(
nqp::isnull(
(my $target := nqp::atkey(
nqp::getattr(self,Map,'$!storage'),
(my $key := key.Str)
))
),
nqp::bindkey(
nqp::getattr(self,Map,'$!storage'),
$key,
nqp::p6scalarwithvalue($!descriptor,assignval)
),
nqp::p6assign($target,assignval)
)
my str $key = key.Str;
my \storage := nqp::getattr(self, Map, '$!storage');
nqp::p6assign(
nqp::ifnull(
nqp::atkey(storage, $key),
nqp::bindkey(storage, $key,
nqp::p6bindattrinvres(nqp::create(Scalar), Scalar, '$!descriptor', $!descriptor))),
assignval)
}

proto method BIND-KEY(|) {*}
Expand Down

0 comments on commit c60a347

Please sign in to comment.