summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-05-21 17:24:37 +0200
committerNicholas Clark <nick@ccl4.org>2009-05-21 17:24:37 +0200
commit0e44608102d0bfb1d574ba4b0c350390ef1d459c (patch)
treec732abd5e51194ede2c5b6dd346d4008b03336fe
parent2243c3b2519b9854cb76fbdb41e692fd0a494fa2 (diff)
downloadperl-0e44608102d0bfb1d574ba4b0c350390ef1d459c.tar.gz
Merge Perl_magic_setisa() and Perl_magic_clearisa(), to remove duplicated logic.
-rw-r--r--embed.fnc2
-rw-r--r--mg.c37
-rw-r--r--proto.h3
3 files changed, 14 insertions, 28 deletions
diff --git a/embed.fnc b/embed.fnc
index 7048e01c24..68f38171c7 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 157d3cdd6e..2147407adf 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 b34e9a8929..78f17ddedb 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)