Skip to content

Commit fb1dc98

Browse files
committed
Perl_newSVrv - after a sv_clear, do the upgrade to SVt_IV inline.
Although this appears in an UNLIKELY branch, this commit shaves off some CPU instructions and may generally help the compiler to optimise the more likely branches.
1 parent ba17861 commit fb1dc98

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sv.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11199,10 +11199,11 @@ Perl_newSVrv(pTHX_ SV *const rv, const char *const classname)
1119911199
const U32 refcnt = SvREFCNT(rv);
1120011200
SvREFCNT(rv) = 0;
1120111201
sv_clear(rv);
11202-
SvFLAGS(rv) = 0;
11202+
SvFLAGS(rv) = SVt_IV;
1120311203
SvREFCNT(rv) = refcnt;
1120411204

11205-
sv_upgrade(rv, SVt_IV);
11205+
SET_SVANY_FOR_BODYLESS_IV(rv);
11206+
SvIV_set(rv, 0);
1120611207
} else if (SvROK(rv)) {
1120711208
SvREFCNT_dec(SvRV(rv));
1120811209
} else {

0 commit comments

Comments
 (0)