summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-07-09 00:03:47 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-07-09 00:03:47 +0200
commitc3a9a7905da9fe1983f7fb4f13851cbd776c98ad (patch)
treedb2497c72c037a350ea12715e350d5c98c13710e /gv.c
parent242f8760e6ec383f070c854a602d038abeaf355a (diff)
downloadperl-c3a9a7905da9fe1983f7fb4f13851cbd776c98ad.tar.gz
Modify the return value of Gv_AMupdate to indicate a compilation error
This way we'll restore most of the performance on object desctruction lost by the previous commit
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/gv.c b/gv.c
index ca8e7a7fe9..f24a7f1531 100644
--- a/gv.c
+++ b/gv.c
@@ -1664,8 +1664,13 @@ Perl_magic_freeovrld(pTHX_ SV *sv, MAGIC *mg)
}
/* Updates and caches the CV's */
+/* Returns:
+ * 1 on success and there is some overload
+ * 0 if there is no overload
+ * -1 if some error occurred and it couldn't croak
+ */
-bool
+int
Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing)
{
dVAR;
@@ -1681,7 +1686,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing)
const AMT * const amtp = (AMT*)mg->mg_ptr;
if (amtp->was_ok_am == PL_amagic_generation
&& amtp->was_ok_sub == newgen) {
- return (bool)AMT_OVERLOADED(amtp);
+ return AMT_OVERLOADED(amtp) ? 1 : 0;
}
sv_unmagic(MUTABLE_SV(stash), PERL_MAGIC_overload_table);
}
@@ -1758,7 +1763,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing)
{
/* Can be an import stub (created by "can"). */
if (destructing) {
- return FALSE;
+ return -1;
}
else {
const char * const name = (gvsv && SvPOK(gvsv)) ? SvPVX_const(gvsv) : "???";
@@ -1797,7 +1802,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash, bool destructing)
AMT_AMAGIC_off(&amt);
sv_magic(MUTABLE_SV(stash), 0, PERL_MAGIC_overload_table,
(char*)&amt, sizeof(AMTS));
- return FALSE;
+ return 0;
}
@@ -1821,7 +1826,7 @@ Perl_gv_handler(pTHX_ HV *stash, I32 id)
do_update:
/* If we're looking up a destructor to invoke, we must avoid
* that Gv_AMupdate croaks, because we might be dying already */
- if (!Gv_AMupdate(stash, id == DESTROY_amg)) {
+ if (Gv_AMupdate(stash, id == DESTROY_amg) == -1) {
/* and if it didn't found a destructor, we fall back
* to a simpler method that will only look for the
* destructor instead of the whole magic */