Skip to content

Commit d999021

Browse files
committed
Simplify SvPV_shrink_to_cur() usage in toke.c
The previous commit modified the definition of `SvPV_shrink_to_cur` so that it does not attempt to reallocate to make unrealistic savings. That made some of the condition checks in toke.c redundant, so this commit removes those.
1 parent b1f270f commit d999021

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

toke.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4423,9 +4423,7 @@ S_scan_const(pTHX_ char *start)
44234423
}
44244424

44254425
/* shrink the sv if we allocated more than we used */
4426-
if (SvCUR(sv) + 5 < SvLEN(sv)) {
4427-
SvPV_shrink_to_cur(sv);
4428-
}
4426+
SvPV_shrink_to_cur(sv);
44294427

44304428
/* return the substring (via pl_yylval) only if we parsed anything */
44314429
if (s > start) {
@@ -11367,9 +11365,7 @@ S_scan_heredoc(pTHX_ char *s)
1136711365
SvREFCNT_dec_NN(newstr);
1136811366
}
1136911367

11370-
if (SvCUR(tmpstr) + 5 < SvLEN(tmpstr)) {
11371-
SvPV_shrink_to_cur(tmpstr);
11372-
}
11368+
SvPV_shrink_to_cur(tmpstr);
1137311369

1137411370
if (!IN_BYTES) {
1137511371
if (UTF && is_utf8_string((U8*)SvPVX_const(tmpstr), SvCUR(tmpstr)))
@@ -11896,10 +11892,7 @@ Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int
1189611892
PL_parser->herelines = herelines;
1189711893

1189811894
/* if we allocated too much space, give some back */
11899-
if (SvCUR(sv) + 5 < SvLEN(sv)) {
11900-
SvLEN_set(sv, SvCUR(sv) + 1);
11901-
SvPV_shrink_to_cur(sv);
11902-
}
11895+
SvPV_shrink_to_cur(sv);
1190311896

1190411897
/* decide whether this is the first or second quoted string we've read
1190511898
for this op

0 commit comments

Comments
 (0)