summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2014-03-10 14:03:09 +0000
committerDavid Mitchell <davem@iabyn.com>2014-03-10 14:03:09 +0000
commit6bb3f245a58d9f11ee03a80a12e3a6a7799b2403 (patch)
treed6741d894a22dc4233a0e1ec46c4c11d10e938ff /pp_ctl.c
parent5d27ee4af18b0f3857a1f951f91473c86da29b62 (diff)
downloadperl-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.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 7b516da59e..3c643d7d1c 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. */