utf8.c: Avoid some extra work
authorKarl Williamson <public@khwilliamson.com>
Wed, 6 Jun 2012 21:40:38 +0000 (15:40 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 7 Jun 2012 15:55:50 +0000 (09:55 -0600)
In the case changed, the output is the input, so can just Copy it
instead of re-deriving it.

utf8.c

diff --git a/utf8.c b/utf8.c
index 5359110..5469a8e 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -2419,9 +2419,11 @@ Perl_to_utf8_case(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp,
         }
     }
 
-    if (!len) /* Neither: just copy.  In other words, there was no mapping
-                defined, which means that the code point maps to itself */
-        len = uvchr_to_utf8(ustrp, uv0) - ustrp;
+    if (!len) { /* There was no mapping defined, which means that the code
+                   point maps to itself */
+        len = UTF8SKIP(p);
+        Copy(p, ustrp, len, U8);
+    }
 
     if (lenp)
         *lenp = len;