diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2014-03-10 14:03:09 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2014-03-10 14:03:09 +0000 |
commit | 6bb3f245a58d9f11ee03a80a12e3a6a7799b2403 (patch) | |
tree | d6741d894a22dc4233a0e1ec46c4c11d10e938ff /pp_ctl.c | |
parent | 5d27ee4af18b0f3857a1f951f91473c86da29b62 (diff) | |
download | perl-6bb3f245a58d9f11ee03a80a12e3a6a7799b2403.tar.gz |
remove a redundant SvTIED_mg from S_do_smartmatch
A non tied HV potentially could be checked twice for being tied. Move
HvUSEDKEYS part to avoid checking var tied twice. The redundant tied check
comes from day 1 of smart match in commit 0d863452f5 . IDK why HV sides
are swapped, but comment it.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -4674,28 +4674,28 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied) /* Check that the key-sets are identical */ HE *he; HV *other_hv = MUTABLE_HV(SvRV(d)); - bool tied = FALSE; - bool other_tied = FALSE; + bool tied; + bool other_tied; U32 this_key_count = 0, other_key_count = 0; HV *hv = MUTABLE_HV(SvRV(e)); DEBUG_M(Perl_deb(aTHX_ " applying rule Hash-Hash\n")); /* Tied hashes don't know how many keys they have. */ - if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) { - tied = TRUE; - } - else if (SvTIED_mg((const SV *)other_hv, PERL_MAGIC_tied)) { - HV * const temp = other_hv; - other_hv = hv; - hv = temp; - tied = TRUE; + tied = cBOOL(SvTIED_mg((SV*)hv, PERL_MAGIC_tied)); + other_tied = cBOOL(SvTIED_mg((const SV *)other_hv, PERL_MAGIC_tied)); + if (!tied ) { + if(other_tied) { + /* swap HV sides */ + HV * const temp = other_hv; + other_hv = hv; + hv = temp; + tied = TRUE; + other_tied = FALSE; + } + else if(HvUSEDKEYS((const HV *) hv) != HvUSEDKEYS(other_hv)) + RETPUSHNO; } - if (SvTIED_mg((const SV *)other_hv, PERL_MAGIC_tied)) - other_tied = TRUE; - - if (!tied && HvUSEDKEYS((const HV *) hv) != HvUSEDKEYS(other_hv)) - RETPUSHNO; /* The hashes have the same number of keys, so it suffices to check that one is a subset of the other. */ |