In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/7777302a0051987e602dfe05c34b52adf18cc9f0?hp=4a1358c2c887560a670a38d1129f8a28120ccfa4>
- Log ----------------------------------------------------------------- commit 7777302a0051987e602dfe05c34b52adf18cc9f0 Author: Steffen Mueller <smuel...@cpan.org> Date: Fri Nov 28 18:05:34 2014 +0100 Attempt to bring newSViv/uv optimization to newRV Cf. bd30fe8921c88e4677c2279b442a56a11ae037b4 for details. M sv.c commit 4d55d9ac67bf8bc58f3fc9563b082459c6a3c22b Author: Steffen Mueller <smuel...@cpan.org> Date: Fri Nov 28 17:34:00 2014 +0100 Repeat newSViv optimization for newSVuv Pretty much the same change as bd30fe8921c88e4677c2279b442a56a11ae037b4 was for newSViv. M sv.c commit d64e7846f909672853db422f93806d57d5a86c1f Author: Steffen Mueller <smuel...@cpan.org> Date: Fri Nov 28 17:33:42 2014 +0100 Branch predictor hint for exceptional branch M sv.c ----------------------------------------------------------------------- Summary of changes: sv.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/sv.c b/sv.c index 68af03c..d2b549e 100644 --- a/sv.c +++ b/sv.c @@ -4446,7 +4446,9 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, SV* sstr, const I32 flags) SvOK_off(dstr); } } - else if (dtype == SVt_PVAV || dtype == SVt_PVHV || dtype == SVt_PVFM) { + else if (UNLIKELY(dtype == SVt_PVAV || dtype == SVt_PVHV + || dtype == SVt_PVFM)) + { const char * const type = sv_reftype(dstr,0); if (PL_op) /* diag_listed_as: Cannot copy to %s */ @@ -9392,8 +9394,29 @@ Perl_newSVuv(pTHX_ const UV u) { SV *sv; + /* Inlining ONLY the small relevant subset of sv_setuv here + * for performance. Makes a significant difference. */ + + /* Using ivs is more efficient than using uvs - see sv_setuv */ + if (u <= (UV)IV_MAX) { + return newSViv((IV)u); + } + new_SV(sv); - sv_setuv(sv,u); + + /* 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; + (void)SvIOK_on(sv); + (void)SvIsUV_on(sv); + + SvUV_set(sv, u); + SvTAINT(sv); + return sv; } @@ -9430,13 +9453,25 @@ SV is B<not> 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; } -- Perl5 Master Repository