Skip to content

Commit

Permalink
Create iterator early, let it serve as check for emptiness
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jul 19, 2017
1 parent 8e96052 commit 710fa80
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/Rakudo/QuantHash.pm
Expand Up @@ -156,11 +156,11 @@ my class Rakudo::QuantHash {
# Return an nqp::list_s of all keys of a QuantHash
method RAW-KEYS(\quanthash) is raw {
nqp::if(
(my $elems := quanthash.RAW-HASH),
(my $elems := quanthash.RAW-HASH)
&& (my $iter := nqp::iterator($elems)),
nqp::stmts(
(my $keys := nqp::setelems(nqp::list_s,nqp::elems($elems))),
(my int $i = -1),
(my $iter := nqp::iterator($elems)),
nqp::while(
$iter,
nqp::bindpos_s(
Expand All @@ -179,11 +179,11 @@ my class Rakudo::QuantHash {
# joined with a null-byte inbetween.
method BAGGY-RAW-KEY-VALUES(\baggy) is raw {
nqp::if(
(my $elems := baggy.RAW-HASH) && nqp::elems($elems),
(my $elems := baggy.RAW-HASH)
&& (my $iter := nqp::iterator($elems)),
nqp::stmts(
(my $list := nqp::setelems(nqp::list_s,nqp::elems($elems))),
(my int $i = -1),
(my $iter := nqp::iterator($elems)),
nqp::while(
$iter,
nqp::stmts(
Expand Down

0 comments on commit 710fa80

Please sign in to comment.