Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make EnumMap.Bool/elems 5% faster
This therefore also applies to Hash.Bool/elems
  • Loading branch information
lizmat committed Jan 12, 2015
1 parent 04ce883 commit 27c2d5a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/core/EnumMap.pm
Expand Up @@ -3,12 +3,10 @@ my class EnumMap does Associative { # declared in BOOTSTRAP
# has Mu $!storage;

multi method Bool(EnumMap:D:) {
nqp::p6bool(nqp::defined($!storage) ?? nqp::elems($!storage) !! 0)
nqp::p6bool(nqp::defined($!storage) && nqp::elems($!storage));
}
method elems(EnumMap:) {
self.DEFINITE && nqp::defined($!storage)
?? nqp::p6box_i(nqp::elems($!storage))
!! 0
method elems(EnumMap:D:) {
nqp::p6box_i(nqp::defined($!storage) && nqp::elems($!storage));
}

multi method ACCEPTS(EnumMap:D: Any $topic) {
Expand Down

0 comments on commit 27c2d5a

Please sign in to comment.