From 540f4522aa40f6672e5e44976a38fae4b39fa3b8 Mon Sep 17 00:00:00 2001 From: Richard Leach Date: Thu, 25 Aug 2022 13:51:15 +0000 Subject: S_scan_heredoc: fresh sv functions close to point of use S_scan_heredoc does a SvGROW on a fresh PVIV. A sv_grow_fresh is more efficient, plus it seems only really needed in the nearby "else" branch. In the "if" branch, sv_setsv_fresh can be used directly. --- toke.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toke.c') diff --git a/toke.c b/toke.c index 607ce0372a..a7601f3b3a 100644 --- a/toke.c +++ b/toke.c @@ -10777,7 +10777,6 @@ S_scan_heredoc(pTHX_ char *s) #endif tmpstr = newSV_type(SVt_PVIV); - SvGROW(tmpstr, 80); if (term == '\'') { op_type = OP_CONST; SvIV_set(tmpstr, -1); @@ -10888,7 +10887,7 @@ S_scan_heredoc(pTHX_ char *s) goto interminable; } - sv_setpvn(tmpstr,d+1,s-d); + sv_setpvn_fresh(tmpstr,d+1,s-d); s += len - 1; /* the preceding stmt passes a newline */ PL_parser->herelines++; @@ -10935,6 +10934,7 @@ S_scan_heredoc(pTHX_ char *s) char *oldbufptr_save; char *oldoldbufptr_save; streaming: + sv_grow_fresh(tmpstr, 80); SvPVCLEAR(tmpstr); /* avoid "uninitialized" warning */ term = PL_tokenbuf[1]; len--; -- cgit v1.2.1