summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-06-06 15:50:53 -0600
committerKarl Williamson <public@khwilliamson.com>2012-06-07 09:55:50 -0600
commitcbe07460d443564aea40e4397ab55080aab2d0b9 (patch)
tree5e0e6e974b709848f0a7bf90f5c3c0d15bfc96b5 /utf8.c
parentdd9267d7ed4287d573abd56d1aadf2152c628baf (diff)
downloadperl-cbe07460d443564aea40e4397ab55080aab2d0b9.tar.gz
utf8.c: Refactor a portion of to_utf8_case()
This routine can never return 0, as if there is no case mapping, the input is used instead. The code point for that input has already been derived earlier in the function, so it doesn't have to be recalculated. And, rearrange the order of things slightly.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/utf8.c b/utf8.c
index 5469a8e139..3afa69c6cd 100644
--- a/utf8.c
+++ b/utf8.c
@@ -2419,16 +2419,23 @@ Perl_to_utf8_case(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp,
}
}
- if (!len) { /* There was no mapping defined, which means that the code
- point maps to itself */
+ if (len) {
+ if (lenp) {
+ *lenp = len;
+ }
+ return valid_utf8_to_uvchr(ustrp, 0);
+ }
+
+ /* Here, there was no mapping defined, which means that the code point maps
+ * to itself. Return the inputs */
len = UTF8SKIP(p);
Copy(p, ustrp, len, U8);
- }
if (lenp)
*lenp = len;
- return len ? valid_utf8_to_uvchr(ustrp, 0) : 0;
+ return uv0;
+
}
STATIC UV