In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/8fbcb657f30d2c6ce842ca969787dcb532341df5?hp=d49cfb746d789072c374f2403d477feb8017ce89>
- Log ----------------------------------------------------------------- commit 8fbcb657f30d2c6ce842ca969787dcb532341df5 Author: Yves Orton <[email protected]> Date: Thu Dec 25 03:24:23 2014 +0100 Rework sv_get_backrefs() so it is simpler, and C++ compliant We unroll hv_backreferences_p() in sv_get_backrefs() so the logic is simpler, (we dont need a **SV for this function), and (hopefully) make it C++ compliant at the same time. M hv.c M sv.c commit 34f2dd859e2563e188f2f6c301b08ba1ce795d73 Author: Yves Orton <[email protected]> Date: Thu Dec 25 03:21:47 2014 +0100 Restructure hv_backreferences_p() so assert makes sense Prior to this patch the assert was meaningless as we would use the argument before we asserted things about it. This patch restructures the logic so we do the asserts first and *then* use the argument. M hv.c commit 5f2e6de730e40b8a110897a11d3e20407b66a38c Author: Yves Orton <[email protected]> Date: Thu Dec 25 03:19:42 2014 +0100 Revert "sv.c: Add cast to make C++ happy" This reverts commit d49cfb746d789072c374f2403d477feb8017ce89. Better patch coming. M sv.c ----------------------------------------------------------------------- Summary of changes: hv.c | 9 +++++---- sv.c | 21 +++++++++------------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/hv.c b/hv.c index 5bab2d7..d5db46f 100644 --- a/hv.c +++ b/hv.c @@ -2447,11 +2447,12 @@ Perl_hv_ename_delete(pTHX_ HV *hv, const char *name, U32 len, U32 flags) AV ** Perl_hv_backreferences_p(pTHX_ HV *hv) { - struct xpvhv_aux * const iter = SvOOK(hv) ? HvAUX(hv) : hv_auxinit(hv); - PERL_ARGS_ASSERT_HV_BACKREFERENCES_P; - - return &(iter->xhv_backreferences); + /* See also Perl_sv_get_backrefs in sv.c where this logic is unrolled */ + { + struct xpvhv_aux * const iter = SvOOK(hv) ? HvAUX(hv) : hv_auxinit(hv); + return &(iter->xhv_backreferences); + } } void diff --git a/sv.c b/sv.c index 0221628..e91f5e9 100644 --- a/sv.c +++ b/sv.c @@ -5950,26 +5950,23 @@ Perl_sv_kill_backrefs() SV * Perl_sv_get_backrefs(pTHX_ SV *const sv) { - SV **svp= NULL; - MAGIC *mg = NULL; + SV *backrefs= NULL; PERL_ARGS_ASSERT_SV_GET_BACKREFS; /* find slot to store array or singleton backref */ if (SvTYPE(sv) == SVt_PVHV) { - if (SvOOK(sv)) - svp = (SV**)Perl_hv_backreferences_p(aTHX_ (HV *)sv); - } else { - if (SvMAGICAL(sv)) - mg = mg_find(sv, PERL_MAGIC_backref); + if (SvOOK(sv)) { + struct xpvhv_aux * const iter = HvAUX((HV *)sv); + backrefs = iter->xhv_backreferences; + } + } else if (SvMAGICAL(sv)) { + MAGIC *mg = mg_find(sv, PERL_MAGIC_backref); if (mg) - svp = &(mg->mg_obj); + backrefs = mg->mg_obj; } - if (svp) - return *svp; - else - return NULL; + return backrefs; } /* Give tsv backref magic if it hasn't already got it, then push a -- Perl5 Master Repository
