From 24b6ef70a86a5d0e357194d0de0d4698aa6f7197 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 4 Jul 2012 14:09:46 -0700 Subject: [PATCH] toke.c:yylex:KEY_sub can use PL_tokenbuf to begin with MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit There is no need to allocate a separate ‘tmpbuf’ and then copy it into PL_tokenbuf afterwards. --- toke.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/toke.c b/toke.c index 8f5475c..901ebe9 100644 --- a/toke.c +++ b/toke.c @@ -8195,7 +8195,7 @@ Perl_yylex(pTHX) case KEY_sub: really_sub: { - char tmpbuf[sizeof PL_tokenbuf]; + char * const tmpbuf = PL_tokenbuf + 1; SSize_t tboffset = 0; expectation attrful; bool have_name, have_proto; @@ -8226,7 +8226,8 @@ Perl_yylex(pTHX) attrful = XATTRBLOCK; /* remember buffer pos'n for later force_word */ tboffset = s - PL_oldbufptr; - d = scan_word(s, tmpbuf, sizeof tmpbuf, TRUE, &len); + d = scan_word(s, tmpbuf, sizeof PL_tokenbuf - 1, TRUE, + &len); #ifdef PERL_MAD if (PL_madskills) nametoke = newSVpvn_flags(s, d - s, SvUTF8(PL_linestr)); @@ -8243,8 +8244,6 @@ Perl_yylex(pTHX) have_name = TRUE; *PL_tokenbuf = '&'; - Copy(tmpbuf, PL_tokenbuf+1, len, char); - PL_tokenbuf[len+1] = '\0'; #ifdef PERL_MAD start_force(0); -- 2.7.4