This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Skip some work for UTF-8 invariant
authorKarl Williamson <khw@cpan.org>
Tue, 20 Dec 2016 18:43:08 +0000 (11:43 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 23 Dec 2016 00:59:10 +0000 (17:59 -0700)
Since these chars are the same when encoded in UTF-8 as when not, no
need to do the extra UTF-8 work.

toke.c

diff --git a/toke.c b/toke.c
index cd01255..8052708 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -10204,15 +10204,13 @@ S_scan_str(pTHX_ char *start, int keep_bracketed_quoted, int keep_delims, int re
 
     /* after skipping whitespace, the next character is the terminator */
     term = *s;
-    if (!UTF) {
+    if (!UTF || UTF8_IS_INVARIANT(term)) {
        termcode = termstr[0] = term;
        termlen = 1;
     }
     else {
        termcode = utf8_to_uvchr_buf((U8*)s, (U8*)PL_bufend, &termlen);
        Copy(s, termstr, termlen, U8);
-       if (!UTF8_IS_INVARIANT(term))
-           has_utf8 = TRUE;
     }
 
     /* mark where we are */