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 | |
parent | 2243c3b2519b9854cb76fbdb41e692fd0a494fa2 (diff) | |
download | perl-0e44608102d0bfb1d574ba4b0c350390ef1d459c.tar.gz |
Merge Perl_magic_setisa() and Perl_magic_clearisa(), to remove duplicated logic.
-rw-r--r-- | embed.fnc | 2 | ||||
-rw-r--r-- | mg.c | 37 | ||||
-rw-r--r-- | proto.h | 3 |
3 files changed, 14 insertions, 28 deletions
@@ -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 @@ -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 @@ -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) |