Skip to content

Commit

Permalink
sv.c: use Perl_sv_grow_fresh & Perl_sv_setvpn_fresh
Browse files Browse the repository at this point in the history
  • Loading branch information
richardleach committed May 26, 2021
1 parent 759ff77 commit b6434e3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sv.c
Expand Up @@ -5733,7 +5733,8 @@ Perl_newSV(pTHX_ const STRLEN len)

new_SV(sv);
if (len) {
sv_grow(sv, len + 1);
sv_upgrade(sv, SVt_PV);
sv_grow_fresh(sv, len + 1);
}
return sv;
}
Expand Down Expand Up @@ -9391,7 +9392,8 @@ Perl_newSVpvn_flags(pTHX_ const char *const s, const STRLEN len, const U32 flags
And we're new code so I'm going to assert this from the start. */
assert(!(flags & ~(SVf_UTF8|SVs_TEMP)));
new_SV(sv);
sv_setpvn(sv,s,len);
sv_upgrade(sv, SVt_PV);
sv_setpvn_fresh(sv,s,len);

/* This code used to do a sv_2mortal(), however we now unroll the call to
* sv_2mortal() and do what it does ourselves here. Since we have asserted
Expand Down Expand Up @@ -9461,7 +9463,8 @@ Perl_newSVpv(pTHX_ const char *const s, const STRLEN len)
SV *sv;

new_SV(sv);
sv_setpvn(sv, s, len || s == NULL ? len : strlen(s));
sv_upgrade(sv, SVt_PV);
sv_setpvn_fresh(sv, s, len || s == NULL ? len : strlen(s));
return sv;
}

Expand All @@ -9483,7 +9486,8 @@ Perl_newSVpvn(pTHX_ const char *const buffer, const STRLEN len)
{
SV *sv;
new_SV(sv);
sv_setpvn(sv,buffer,len);
sv_upgrade(sv, SVt_PV);
sv_setpvn_fresh(sv,buffer,len);
return sv;
}

Expand Down

0 comments on commit b6434e3

Please sign in to comment.