In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/6bb3f245a58d9f11ee03a80a12e3a6a7799b2403?hp=5d27ee4af18b0f3857a1f951f91473c86da29b62>
- Log ----------------------------------------------------------------- commit 6bb3f245a58d9f11ee03a80a12e3a6a7799b2403 Author: Daniel Dragan <[email protected]> Date: Mon Mar 10 14:03:09 2014 +0000 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. ----------------------------------------------------------------------- Summary of changes: pp_ctl.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/pp_ctl.c b/pp_ctl.c index 7b516da..3c643d7 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -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. */ -- Perl5 Master Repository
