summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-03-29 20:03:18 +0100
committerNicholas Clark <nick@ccl4.org>2009-03-29 20:06:53 +0100
commit99ab892b6470bcd28bad5512a942b608496ebf8f (patch)
tree1614b48285f126c71144d5542a01e75a9b0e6ab6 /op.c
parent9340c80aaec7d3857f387eea86207c1a9604b2ad (diff)
downloadperl-99ab892b6470bcd28bad5512a942b608496ebf8f.tar.gz
Change Perl_newCONSTSUB() so that a NULL sv generates an empty list return.
Don't call DESTROY if it's a constant subroutine.
Diffstat (limited to 'op.c')
-rw-r--r--op.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/op.c b/op.c
index 78d99905da..b88931960f 100644
--- a/op.c
+++ b/op.c
@@ -5949,6 +5949,11 @@ S_process_special_blocks(pTHX_ const char *const fullname, GV *const gv,
Creates a constant sub equivalent to Perl C<sub FOO () { 123 }> which is
eligible for inlining at compile-time.
+Passing NULL for SV creates a constant sub equivalent to C<sub BAR () {}>,
+which won't be called if used as a destructor, but will suppress the overhead
+of a call to C<AUTOLOAD>. (This form, however, isn't eligible for inlining at
+compile time.)
+
=cut
*/
@@ -8968,6 +8973,7 @@ const_sv_xsub(pTHX_ CV* cv)
{
dVAR;
dXSARGS;
+ SV *const sv = MUTABLE_SV(XSANY.any_ptr);
if (items != 0) {
NOOP;
#if 0
@@ -8975,8 +8981,11 @@ const_sv_xsub(pTHX_ CV* cv)
HvNAME_get(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv)));
#endif
}
+ if (!sv) {
+ XSRETURN(0);
+ }
EXTEND(sp, 1);
- ST(0) = MUTABLE_SV(XSANY.any_ptr);
+ ST(0) = sv;
XSRETURN(1);
}