Skip to content

Commit ba17861

Browse files
committed
Perl_newSV - entirely create the new SV within this function.
Since `new_XPV()` was added, this function can handle both branches of `if (len)` without needing to call any other function. This should be slightly more efficient for both branches.
1 parent 81dcd77 commit ba17861

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sv.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6275,10 +6275,14 @@ Perl_newSV(pTHX_ const STRLEN len)
62756275
{
62766276
SV *sv;
62776277

6278-
if (!len)
6279-
new_SV(sv);
6280-
else {
6281-
sv = newSV_type(SVt_PV);
6278+
new_SV(sv);
6279+
if (len) {
6280+
SvFLAGS(sv) = SVt_PV;
6281+
SvANY(sv) = new_XPV();
6282+
6283+
SvCUR_set(sv, 0);
6284+
SvLEN_set(sv, 0);
6285+
62826286
sv_grow_fresh(sv, len + 1);
62836287
}
62846288
return sv;

0 commit comments

Comments
 (0)