Skip to content
Permalink
Browse files

Simplify Map.Hash

Removes one call to nqp::elems, because we need the iterator we can use
that as the condition for the if (as an iterator on an empty hash will
always start out to be false)
  • Loading branch information...
lizmat committed Dec 29, 2018
1 parent 5cf65b5 commit 87698317a962f2e43723a3553cbd35b5845ab568
Showing with 1 addition and 2 deletions.
  1. +1 −2 src/core/Map.pm6
@@ -56,11 +56,10 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP

multi method Hash(Map:U:) { Hash }
multi method Hash(Map:D: --> Hash:D) {
if nqp::elems($!storage) {
if nqp::iterator($!storage) -> \iter {
my \hash := nqp::create(Hash);
my \storage := nqp::bindattr(hash,Map,'$!storage',nqp::hash);
my \descriptor := BEGIN nqp::getcurhllsym('default_cont_spec');
my \iter := nqp::iterator(nqp::getattr(self,Map,'$!storage'));
nqp::while(
iter,
nqp::bindkey(

0 comments on commit 8769831

Please sign in to comment.
You can’t perform that action at this time.