Skip to content

Commit

Permalink
Perl_newSVnv: simplify SV creation and SvNV_set
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
richardleach authored and xenu committed Mar 20, 2022
1 parent a933fcc commit b944b7b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sv.c
Original file line number Diff line number Diff line change
Expand Up @@ -9666,10 +9666,12 @@ The reference count for the SV is set to 1.
SV *
Perl_newSVnv(pTHX_ const NV n)
{
SV *sv;
SV *sv = newSV_type(SVt_NV);
(void)SvNOK_on(sv);

SvNV_set(sv, n);
SvTAINT(sv);

new_SV(sv);
sv_setnv(sv,n);
return sv;
}

Expand Down

0 comments on commit b944b7b

Please sign in to comment.