summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2022-11-28 13:28:46 +0000
committerRichard Leach <richardleach@users.noreply.github.com>2022-11-30 00:45:02 +0000
commit54ca894738d71b8a053b5405699c66b8c0bd346d (patch)
treecfd73c82af0aeb53c5f048b73e64c05fd313b59d
parenta91f26aeba97b32d0b4e53a62efa08351a1e8b6f (diff)
downloadperl-54ca894738d71b8a053b5405699c66b8c0bd346d.tar.gz
Replace SvGROW with sv_grow_fresh in perl.c, pp_sys.c, toke.c
Changed: * perl.c - Perl_moreswitches * pp_sys.c - pp_sysread * toke.c - Perl_scan_str In each of the above functions, one instance of SvGROW on a new SVt_PV can be swapped for the more efficient sv_grow_fresh. In two of the instances, the calls used to create the the SVt_PV have also been streamlined. There should not be any functional change as a result of this commit.
-rw-r--r--perl.c4
-rw-r--r--pp_sys.c5
-rw-r--r--toke.c2
3 files changed, 5 insertions, 6 deletions
diff --git a/perl.c b/perl.c
index 8ce14c67af..835d77e771 100644
--- a/perl.c
+++ b/perl.c
@@ -3554,8 +3554,8 @@ Perl_moreswitches(pTHX_ const char *s)
numlen = 0;
s--;
}
- PL_rs = newSVpvs("");
- tmps = (U8*) SvGROW(PL_rs, (STRLEN)(UVCHR_SKIP(rschar) + 1));
+ PL_rs = newSV((STRLEN)(UVCHR_SKIP(rschar) + 1));
+ tmps = (U8*)SvPVCLEAR_FRESH(PL_rs);
uvchr_to_utf8(tmps, rschar);
SvCUR_set(PL_rs, UVCHR_SKIP(rschar));
SvUTF8_on(PL_rs);
diff --git a/pp_sys.c b/pp_sys.c
index 3c831408e2..26a9dda006 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1854,9 +1854,8 @@ PP(pp_sysread)
reading to: */
SvCUR_set(bufsv, offset);
- read_target = sv_newmortal();
- SvUPGRADE(read_target, SVt_PV);
- buffer = SvGROW(read_target, (STRLEN)(length + 1));
+ read_target = newSV_type_mortal(SVt_PV);
+ buffer = sv_grow_fresh(read_target, (STRLEN)(length + 1));
}
if (PL_op->op_type == OP_SYSREAD) {
diff --git a/toke.c b/toke.c
index edc2690934..7abc250a96 100644
--- a/toke.c
+++ b/toke.c
@@ -11488,7 +11488,7 @@ Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int
/* create a new SV to hold the contents. 79 is the SV's initial length.
What a random number. */
sv = newSV_type(SVt_PVIV);
- SvGROW(sv, 79);
+ sv_grow_fresh(sv, 79);
SvIV_set(sv, close_delim_code);
(void)SvPOK_only(sv); /* validate pointer */