utf8.c: Expand use of refactored to_uni_lower
authorKarl Williamson <public@khwilliamson.com>
Wed, 9 Nov 2011 05:05:25 +0000 (22:05 -0700)
committerKarl Williamson <public@khwilliamson.com>
Wed, 9 Nov 2011 05:38:38 +0000 (22:38 -0700)
The new function split out from to_uni_lower is now called when
appropriate from to_utf8_lower.

And to_uni_lower no longer calls to_utf8_lower, using the macro instead,
saving a function call and duplicate work

utf8.c

diff --git a/utf8.c b/utf8.c
index 919d1cc..8c87d21 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -1383,6 +1383,8 @@ S_to_lower_latin1(pTHX_ const U8 c, U8* p, STRLEN *lenp)
 UV
 Perl_to_uni_lower(pTHX_ UV c, U8* p, STRLEN *lenp)
 {
+    dVAR;
+
     PERL_ARGS_ASSERT_TO_UNI_LOWER;
 
     if (c < 256) {
@@ -1390,7 +1392,7 @@ Perl_to_uni_lower(pTHX_ UV c, U8* p, STRLEN *lenp)
     }
 
     uvchr_to_utf8(p, c);
-    return to_utf8_lower(p, p, lenp);
+    return CALL_LOWER_CASE(p, p, lenp);
 }
 
 UV
@@ -2065,6 +2067,13 @@ Perl_to_utf8_lower(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp)
 
     PERL_ARGS_ASSERT_TO_UTF8_LOWER;
 
+    if (UTF8_IS_INVARIANT(*p)) {
+       return to_lower_latin1(*p, ustrp, lenp);
+    }
+    else if UTF8_IS_DOWNGRADEABLE_START(*p) {
+       return to_lower_latin1(TWO_BYTE_UTF8_TO_UNI(*p, *(p+1)), ustrp, lenp);
+    }
+
     return CALL_LOWER_CASE(p, ustrp, lenp);
 }