Skip to content

Commit

Permalink
Simplify Any (elem) Map
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Aug 8, 2018
1 parent 3684154 commit 81bcc54
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/core/set_elem.pm6
Expand Up @@ -9,8 +9,7 @@
proto sub infix:<(elem)>($, $, *% --> Bool:D) is pure {*}
multi sub infix:<(elem)>(Str:D $a, Map:D $b --> Bool:D) {
nqp::p6bool(
(my $storage := nqp::getattr(nqp::decont($b),Map,'$!storage'))
&& nqp::elems($storage)
nqp::elems(my $storage := nqp::getattr(nqp::decont($b),Map,'$!storage'))
&& nqp::if(
nqp::eqaddr($b.keyof,Str(Any)),
nqp::atkey($storage,$a), # normal hash
Expand All @@ -28,9 +27,9 @@ multi sub infix:<(elem)>(Str:D $a, Map:D $b --> Bool:D) {
}
multi sub infix:<(elem)>(Any $a, Map:D $b --> Bool:D) {
nqp::p6bool(
(my $storage := nqp::getattr(nqp::decont($b),Map,'$!storage'))
&& nqp::elems($storage) # haz a haystack
&& nqp::not_i(nqp::eqaddr($b.keyof,Str(Any))) # is object hash
nqp::elems( # haz a haystack
my $storage := nqp::getattr(nqp::decont($b),Map,'$!storage')
) && nqp::not_i(nqp::eqaddr($b.keyof,Str(Any))) # is object hash
&& nqp::getattr(
nqp::ifnull(
nqp::atkey($storage,$a.WHICH), # exists
Expand Down

0 comments on commit 81bcc54

Please sign in to comment.