Skip to content

Commit b944b7b

Browse files
richardleachxenu
authored andcommitted
Perl_newSVnv: simplify SV creation and SvNV_set
The function can be simplified by using the now-inlined newSV_type function, directly using SvNV_set, and twiddling the required flags. This cuts out any function call overhead, a switch statement leading to a sv_upgrade(sv, SVt_NV) call, and a touch more bit-twiddling than is necessary.
1 parent a933fcc commit b944b7b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sv.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9666,10 +9666,12 @@ The reference count for the SV is set to 1.
96669666
SV *
96679667
Perl_newSVnv(pTHX_ const NV n)
96689668
{
9669-
SV *sv;
9669+
SV *sv = newSV_type(SVt_NV);
9670+
(void)SvNOK_on(sv);
9671+
9672+
SvNV_set(sv, n);
9673+
SvTAINT(sv);
96709674

9671-
new_SV(sv);
9672-
sv_setnv(sv,n);
96739675
return sv;
96749676
}
96759677

0 commit comments

Comments
 (0)