From 7777302a0051987e602dfe05c34b52adf18cc9f0 Mon Sep 17 00:00:00 2001 From: Steffen Mueller Date: Fri, 28 Nov 2014 18:05:34 +0100 Subject: Attempt to bring newSViv/uv optimization to newRV Cf. bd30fe8921c88e4677c2279b442a56a11ae037b4 for details. --- sv.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'sv.c') diff --git a/sv.c b/sv.c index 9c5e56382f..d2b549e22e 100644 --- a/sv.c +++ b/sv.c @@ -9453,13 +9453,25 @@ SV is B incremented. SV * Perl_newRV_noinc(pTHX_ SV *const tmpRef) { - SV *sv = newSV_type(SVt_IV); + SV *sv; PERL_ARGS_ASSERT_NEWRV_NOINC; + new_SV(sv); + + /* We're starting from SVt_FIRST, so provided that's + * actual 0, we don't have to unset any SV type flags + * to promote to SVt_IV. */ + assert(SVt_FIRST == 0); + + SET_SVANY_FOR_BODYLESS_IV(sv); + SvFLAGS(sv) |= SVt_IV; + SvROK_on(sv); + SvIV_set(sv, 0); + SvTEMP_off(tmpRef); SvRV_set(sv, tmpRef); - SvROK_on(sv); + return sv; } -- cgit v1.2.1