Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
STORE_AT_KEY doesn't return anything
Makes initialization of hashes about 10% faster
  • Loading branch information
lizmat authored and niner committed Jan 26, 2016
1 parent 74dd4e2 commit b6c3321
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/core/Hash.pm
Expand Up @@ -73,10 +73,9 @@ my class Hash { # declared in BOOTSTRAP
self.DUMP-OBJECT-ATTRS($attrs, :$indent-step, :%ctx);
}

method STORE_AT_KEY(\key, Mu $x) is raw {
method STORE_AT_KEY(\key, Mu $x --> Nil) {
my $v := nqp::p6scalarfromdesc($!descriptor);
nqp::findmethod(Map, 'STORE_AT_KEY')(self, key, $v = $x);
$v;
}

# introspection
Expand Down Expand Up @@ -299,7 +298,7 @@ my class Hash { # declared in BOOTSTRAP
);
}
}
method STORE_AT_KEY(Str \key, TValue $x) is raw {
method STORE_AT_KEY(Str \key, TValue $x --> Nil) {
my $v :=
nqp::p6scalarfromdesc(nqp::getattr(self, Hash, '$!descriptor'));
nqp::findmethod(Map, 'STORE_AT_KEY')(self, key, $v = $x);
Expand Down Expand Up @@ -362,7 +361,7 @@ my class Hash { # declared in BOOTSTRAP
});
}
}
method STORE_AT_KEY(TKey \key, TValue $x) is raw {
method STORE_AT_KEY(TKey \key, TValue $x --> Nil) {
my $key_which = key.WHICH;
nqp::defined(nqp::getattr(self, $?CLASS, '$!keys')) ||
nqp::bindattr(self, $?CLASS, '$!keys', nqp::hash());
Expand Down
6 changes: 3 additions & 3 deletions src/core/Map.pm
Expand Up @@ -203,13 +203,13 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
self
}

proto method STORE_AT_KEY(|) is raw { * }
multi method STORE_AT_KEY(Str \key, Mu \value) is raw {
proto method STORE_AT_KEY(|) { * }
multi method STORE_AT_KEY(Str \key, Mu \value --> Nil) {
nqp::defined($!storage) ||
nqp::bindattr(self, Map, '$!storage', nqp::hash());
nqp::bindkey($!storage, nqp::unbox_s(key), value)
}
multi method STORE_AT_KEY(\key, Mu \value) is raw {
multi method STORE_AT_KEY(\key, Mu \value --> Nil) {
nqp::defined($!storage) ||
nqp::bindattr(self, Map, '$!storage', nqp::hash());
nqp::bindkey($!storage, nqp::unbox_s(key.Str), value)
Expand Down

0 comments on commit b6c3321

Please sign in to comment.