Skip to content

Commit

Permalink
Make Setty.roll about 11x faster
Browse files Browse the repository at this point in the history
By using R:Q.ROLL, which prevents having to build lists.
  • Loading branch information
lizmat committed May 21, 2017
1 parent 0e9ee0d commit e6192ca
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/Setty.pm
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ my role Setty does QuantHash {
multi method pick(Setty:D: $count) { self.hll_hash.values.pick($count) }

proto method roll(|) { * }
multi method roll(Setty:D:) { self.hll_hash.values.roll() }
multi method roll(Setty:D:) {
nqp::if(
$!elems,
nqp::iterval(Rakudo::QuantHash.ROLL($!elems)),
Nil
)
}
multi method roll(Setty:D: $count) { self.hll_hash.values.roll($count) }

multi method EXISTS-KEY(Setty:D: \k --> Bool:D) {
Expand Down

0 comments on commit e6192ca

Please sign in to comment.