From: Nicholas Clark Date: Thu, 21 May 2009 15:24:37 +0000 (+0200) Subject: Merge Perl_magic_setisa() and Perl_magic_clearisa(), to remove duplicated logic. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0e44608102d0bfb1d574ba4b0c350390ef1d459c;p=p5sagit%2Fp5-mst-13.2.git Merge Perl_magic_setisa() and Perl_magic_clearisa(), to remove duplicated logic. --- diff --git a/embed.fnc b/embed.fnc index 7048e01..68f3817 100644 --- a/embed.fnc +++ b/embed.fnc @@ -533,7 +533,7 @@ Apd |UV |grok_oct |NN const char* start|NN STRLEN* len_p|NN I32* flags|NULLOK NV p |int |magic_clearenv |NN SV* sv|NN MAGIC* mg p |int |magic_clear_all_env|NN SV* sv|NN MAGIC* mg dp |int |magic_clearhint|NN SV* sv|NN MAGIC* mg -p |int |magic_clearisa |NN SV* sv|NN MAGIC* mg +p |int |magic_clearisa |NULLOK SV* sv|NN MAGIC* mg p |int |magic_clearpack|NN SV* sv|NN MAGIC* mg p |int |magic_clearsig |NN SV* sv|NN MAGIC* mg p |int |magic_existspack|NN SV* sv|NN const MAGIC* mg diff --git a/mg.c b/mg.c index 157d3cd..2147407 100644 --- a/mg.c +++ b/mg.c @@ -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 diff --git a/proto.h b/proto.h index b34e9a8..78f17dd 100644 --- a/proto.h +++ b/proto.h @@ -1519,10 +1519,9 @@ PERL_CALLCONV int Perl_magic_clearhint(pTHX_ SV* sv, MAGIC* mg) assert(sv); assert(mg) PERL_CALLCONV int Perl_magic_clearisa(pTHX_ SV* sv, MAGIC* mg) - __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); #define PERL_ARGS_ASSERT_MAGIC_CLEARISA \ - assert(sv); assert(mg) + assert(mg) PERL_CALLCONV int Perl_magic_clearpack(pTHX_ SV* sv, MAGIC* mg) __attribute__nonnull__(pTHX_1)