summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorDoug MacEachern <dougm@covalent.net>2001-01-06 01:30:05 -0800
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-08 02:17:43 +0000
commitadb5a9ae91a0bed93d396bb0abda99831f9e2e6f (patch)
tree2ada7ac888d36771258146ab10fa96744bfa5546 /gv.c
parent6401474f95a5a7abff57e1a8f41e12e1f064984a (diff)
downloadperl-adb5a9ae91a0bed93d396bb0abda99831f9e2e6f.tar.gz
[patch] xsub AUTOLOAD fix/optimization
Message-ID: <Pine.LNX.4.10.10101060924280.24460-100000@mojo.covalent.net> Allow AUTOLOAD to be an xsub and allow such xsubs to avoid use of $AUTOLOAD. p4raw-id: //depot/perl@8362
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/gv.c b/gv.c
index 04a365ff73..f2931aef67 100644
--- a/gv.c
+++ b/gv.c
@@ -412,7 +412,7 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method)
return Nullgv;
cv = GvCV(gv);
- if (!CvROOT(cv))
+ if (!(CvROOT(cv) || CvXSUB(cv)))
return Nullgv;
/*
@@ -424,6 +424,20 @@ Perl_gv_autoload4(pTHX_ HV *stash, const char *name, STRLEN len, I32 method)
"Use of inherited AUTOLOAD for non-method %s::%.*s() is deprecated",
HvNAME(stash), (int)len, name);
+#ifndef USE_THREADS
+ if (CvXSUB(cv)) {
+ /* rather than lookup/init $AUTOLOAD here
+ * only to have the XSUB do another lookup for $AUTOLOAD
+ * and split that value on the last '::',
+ * pass along the same data via some unused fields in the CV
+ */
+ CvSTASH(cv) = stash;
+ SvPVX(cv) = (char *)name; /* cast to loose constness warning */
+ SvCUR(cv) = len;
+ return gv;
+ }
+#endif
+
/*
* Given &FOO::AUTOLOAD, set $FOO::AUTOLOAD to desired function name.
* The subroutine's original name may not be "AUTOLOAD", so we don't