summaryrefslogtreecommitdiff
path: root/sv.h
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2014-10-04 02:14:02 -0400
committerFather Chrysostomos <sprout@cpan.org>2014-10-04 09:38:43 -0700
commitff121dc6349d6a8a9f9fa598e3955c1d701e3f60 (patch)
tree7fdf5a89aae217be60f81d40f1c37cb71dfbd929 /sv.h
parent2ff4512f4d92cb81d1db548ba0655eb9bfb081e3 (diff)
downloadperl-ff121dc6349d6a8a9f9fa598e3955c1d701e3f60.tar.gz
optimize SV creation funcs in sv.c
In Perl_newSV, the sv_upgrade is redundant, except to protect against a segv in blindly SV body derefing SvGROW (but not in sv_grow). sv_grow has always upgraded a non-PV SV to PV. So don't it here. Since a new SV will never have be a COW, have a SvLEN or a body, all of which SvGROW uses, just call sv_grow. Less branching, and smaller code that way. In Perl_newSV_type, give a hint to compiler that if a platform's symbol visibility allows inlining, and newSV_type's arg is the base type (currently SVt_NULL, maybe SVt_IV in future (see ML)), to possibly inline new_SV into the caller and remove the sv_upgrade call. Also don't call sv_upgrade if it isn't needed (SVt_NULL) in the public symbol version. The redundant sv_upgrade then sv_grow goes to commit 79072805bf "perl 5.0 alpha 2". VC 2003 -01 32 bit threaded machine code size in bytes of 2 functions Perl_newSV_type before 0x2f after 0x29 Perl_newSV before 0x48 after 0x28
Diffstat (limited to 'sv.h')
-rw-r--r--sv.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/sv.h b/sv.h
index 5e0139086e..8c751dcd2b 100644
--- a/sv.h
+++ b/sv.h
@@ -176,6 +176,9 @@ typedef enum {
#if defined(PERL_IN_HV_C) || defined(PERL_IN_XS_APITEST)
#define HE_SVSLOT SVt_NULL
#endif
+#ifdef PERL_IN_SV_C
+# define SVt_FIRST SVt_NULL /* the type of SV that new_SV() in sv.c returns */
+#endif
#define PERL_ARENA_ROOTS_SIZE (SVt_LAST)