diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-05-21 17:24:37 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-05-21 17:24:37 +0200 |
commit | 0e44608102d0bfb1d574ba4b0c350390ef1d459c (patch) | |
tree | c732abd5e51194ede2c5b6dd346d4008b03336fe /mg.c | |
parent | 2243c3b2519b9854cb76fbdb41e692fd0a494fa2 (diff) | |
download | perl-0e44608102d0bfb1d574ba4b0c350390ef1d459c.tar.gz |
Merge Perl_magic_setisa() and Perl_magic_clearisa(), to remove duplicated logic.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 37 |
1 files changed, 12 insertions, 25 deletions
@@ -1532,8 +1532,6 @@ int Perl_magic_setisa(pTHX_ SV *sv, MAGIC *mg) { dVAR; - HV* stash; - PERL_ARGS_ASSERT_MAGIC_SETISA; PERL_UNUSED_ARG(sv); @@ -1541,29 +1539,10 @@ Perl_magic_setisa(pTHX_ SV *sv, MAGIC *mg) if (PL_delaymagic & DM_ARRAY && mg->mg_type == PERL_MAGIC_isaelem) return 0; - /* Bail out if destruction is going on */ - if(PL_dirty) return 0; - - /* XXX Once it's possible, we need to - detect that our @ISA is aliased in - other stashes, and act on the stashes - of all of the aliases */ - - /* The first case occurs via setisa, - the second via setisa_elem, which - calls this same magic */ - stash = GvSTASH( - SvTYPE(mg->mg_obj) == SVt_PVGV - ? (const GV *)mg->mg_obj - : (const GV *)mg_find(mg->mg_obj, PERL_MAGIC_isa)->mg_obj - ); - - if (stash) - mro_isa_changed_in(stash); - - return 0; + return magic_clearisa(NULL, mg); } +/* sv of NULL signifies that we're acting as magic_setisa. */ int Perl_magic_clearisa(pTHX_ SV *sv, MAGIC *mg) { @@ -1575,9 +1554,17 @@ Perl_magic_clearisa(pTHX_ SV *sv, MAGIC *mg) /* Bail out if destruction is going on */ if(PL_dirty) return 0; - av_clear(MUTABLE_AV(sv)); + if (sv) + av_clear(MUTABLE_AV(sv)); - /* XXX see comments in magic_setisa */ + /* XXX Once it's possible, we need to + detect that our @ISA is aliased in + other stashes, and act on the stashes + of all of the aliases */ + + /* The first case occurs via setisa, + the second via setisa_elem, which + calls this same magic */ stash = GvSTASH( SvTYPE(mg->mg_obj) == SVt_PVGV ? (const GV *)mg->mg_obj |