develooper Front page | perl.perl5.porters | Postings from January 2001

[patch] xsub AUTOLOAD fix/optimization

Thread Next
From:
Doug MacEachern
Date:
January 6, 2001 09:26
Subject:
[patch] xsub AUTOLOAD fix/optimization
Message ID:
Pine.LNX.4.10.10101060924280.24460-100000@mojo.covalent.net
the first hunk allows AUTOLOAD to be an xsub.  the second allows such
xsubs to avoid use of $AUTOLOAD with some unused fields in the CV.

Index: gv.c
===================================================================
RCS file: /usr/local/cvs_repository/perl-current-mirror/gv.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 gv.c
--- gv.c	2001/01/04 01:55:27	1.1.1.1
+++ gv.c	2001/01/06 17:27:08
@@ -412,7 +412,7 @@
 	return Nullgv;
     cv = GvCV(gv);
 
-    if (!CvROOT(cv))
+    if (!(CvROOT(cv) || CvXSUB(cv)))
 	return Nullgv;
 
     /*
@@ -423,6 +423,20 @@
 	Perl_warner(aTHX_ WARN_DEPRECATED,
 	  "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.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About