Skip to content

Commit c7342b0

Browse files
richardleachkhwilliamson
authored andcommitted
Perl_sv_clear: faster treatment of bodyless NVs
The existing fast path for SVt_NULL/SVt_IV can also be used for bodyless SVt_NVs.
1 parent 2664c46 commit c7342b0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sv.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6623,8 +6623,11 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
66236623

66246624
assert(SvREFCNT(sv) == 0);
66256625
assert(SvTYPE(sv) != (svtype)SVTYPEMASK);
6626-
6626+
#if NVSIZE <= IVSIZE
6627+
if (type <= SVt_NV) {
6628+
#else
66276629
if (type <= SVt_IV) {
6630+
#endif
66286631
/* Historically this check on type was needed so that the code to
66296632
* free bodies wasn't reached for these types, because the arena
66306633
* slots were re-used for HEs and pointer table entries. The
@@ -6646,6 +6649,9 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
66466649
* path, as SvPVX() doesn't point to valid memory.
66476650
*
66486651
* Hence this code is still the most efficient way to handle this.
6652+
*
6653+
* Additionally, for bodyless NVs, riding this branch is more
6654+
* efficient than stepping through the general logic.
66496655
*/
66506656

66516657
if (SvROK(sv))

0 commit comments

Comments
 (0)