diff options
author | Karl Williamson <public@khwilliamson.com> | 2011-10-16 13:36:36 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2011-10-17 21:52:17 -0600 |
commit | bca00c02a54ca312397c6b26baf3012ac5f7b9c5 (patch) | |
tree | 9384d2fe7e44b7a3e618e32086662c9304674594 /utf8.c | |
parent | 77a6d8568e288ad300ad7f0805946559b4ec28d1 (diff) | |
download | perl-bca00c02a54ca312397c6b26baf3012ac5f7b9c5.tar.gz |
utf8.c: Don't use swash for to_uni_lower() latin1 calls
The lowercase of latin-1 range code points is known to the perl core, so
for those we can short-ciruit converting to utf8 and reading in a swash
Diffstat (limited to 'utf8.c')
-rw-r--r-- | utf8.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -1346,8 +1346,24 @@ Perl_to_uni_lower(pTHX_ UV c, U8* p, STRLEN *lenp) { PERL_ARGS_ASSERT_TO_UNI_LOWER; - uvchr_to_utf8(p, c); - return to_utf8_lower(p, p, lenp); + if (c > 255) { + uvchr_to_utf8(p, c); + return to_utf8_lower(p, p, lenp); + } + + /* We have the latin1-range values compiled into the core, so just use + * those, converting the result to utf8 */ + c = toLOWER_LATIN1(c); + if (UNI_IS_INVARIANT(c)) { + *p = c; + *lenp = 1; + } + else { + *p = UTF8_TWO_BYTE_HI(c); + *(p+1) = UTF8_TWO_BYTE_LO(c); + *lenp = 2; + } + return c; } UV |