This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Speed up utf8.c a bit
authorAndy Lester <andy@petdance.com>
Thu, 11 May 2006 22:41:01 +0000 (17:41 -0500)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 12 May 2006 12:23:03 +0000 (12:23 +0000)
Message-ID: <20060512034101.GA10709@petdance.com>

p4raw-id: //depot/perl@28176

utf8.c

diff --git a/utf8.c b/utf8.c
index d0cbb4e..dad7920 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -332,13 +332,12 @@ Perl_is_utf8_string_loclen(pTHX_ const U8 *s, STRLEN len, const U8 **ep, STRLEN
     const U8* x = s;
     const U8* send;
     STRLEN c;
+    STRLEN outlen = 0;
     PERL_UNUSED_CONTEXT;
 
     if (!len)
         len = strlen((const char *)s);
     send = s + len;
-    if (el)
-        *el = 0;
 
     while (x < send) {
         /* Inline the easy bits of is_utf8_char() here for speed... */
@@ -362,17 +361,16 @@ Perl_is_utf8_string_loclen(pTHX_ const U8 *s, STRLEN len, const U8 **ep, STRLEN
                 goto out;
         }
          x += c;
-        if (el)
-            (*el)++;
+        outlen++;
     }
 
  out:
+    if (el)
+        *el = outlen;
+
     if (ep)
         *ep = x;
-    if (x != send)
-       return FALSE;
-
-    return TRUE;
+    return (x == send);
 }
 
 /*