Skip to content

Commit 5234f32

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 5e2b259 commit 5234f32

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
@@ -4422,9 +4422,7 @@ S_scan_const(pTHX_ char *start)
44224422
}
44234423

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

44294427
/* return the substring (via pl_yylval) only if we parsed anything */
44304428
if (s > start) {
@@ -11348,9 +11346,7 @@ S_scan_heredoc(pTHX_ char *s)
1134811346
SvREFCNT_dec_NN(newstr);
1134911347
}
1135011348

11351-
if (SvCUR(tmpstr) + 5 < SvLEN(tmpstr)) {
11352-
SvPV_shrink_to_cur(tmpstr);
11353-
}
11349+
SvPV_shrink_to_cur(tmpstr);
1135411350

1135511351
if (!IN_BYTES) {
1135611352
if (UTF && is_utf8_string((U8*)SvPVX_const(tmpstr), SvCUR(tmpstr)))
@@ -11877,10 +11873,7 @@ Perl_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int
1187711873
PL_parser->herelines = herelines;
1187811874

1187911875
/* if we allocated too much space, give some back */
11880-
if (SvCUR(sv) + 5 < SvLEN(sv)) {
11881-
SvLEN_set(sv, SvCUR(sv) + 1);
11882-
SvPV_shrink_to_cur(sv);
11883-
}
11876+
SvPV_shrink_to_cur(sv);
1188411877

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

0 commit comments

Comments
 (0)