summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2021-05-24 00:33:36 +0100
committerxenu <me@xenu.pl>2022-03-20 22:14:09 +0100
commitb944b7ba26833a5a2716dc6cc2542a994ff63c2c (patch)
tree3edb7385263b4b2f7b4857d5f519725e436f50de /sv.c
parenta933fcc5f0f338b86c0f40d0e43389770419ed70 (diff)
downloadperl-b944b7ba26833a5a2716dc6cc2542a994ff63c2c.tar.gz
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.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sv.c b/sv.c
index bcddac61c1..b32e1bf145 100644
--- a/sv.c
+++ b/sv.c
@@ -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;
}