summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-06-26 15:30:59 -0600
committerKarl Williamson <public@khwilliamson.com>2013-08-29 09:56:09 -0600
commitd943212517d35e9f03278a2209388b93f634664a (patch)
treec1ef789af97ff99a511ae5c842604a245f8fc611 /utf8.c
parenta3481822e07c32c1f394cd35adc5080a45f628d7 (diff)
downloadperl-d943212517d35e9f03278a2209388b93f634664a.tar.gz
utf8.c: Move some code around for speed
This is a micro optimization. We now check for a common case and return if found, before checking for a relatively uncommon case.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/utf8.c b/utf8.c
index 20d7aca261..1647f188d2 100644
--- a/utf8.c
+++ b/utf8.c
@@ -100,6 +100,11 @@ Perl_uvoffuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
{
PERL_ARGS_ASSERT_UVOFFUNI_TO_UTF8_FLAGS;
+ if (UNI_IS_INVARIANT(uv)) {
+ *d++ = (U8) LATIN1_TO_NATIVE(uv);
+ return d;
+ }
+
/* The first problematic code point is the first surrogate */
if (uv >= UNICODE_SURROGATE_FIRST
&& ckWARN4_d(WARN_UTF8, WARN_SURROGATE, WARN_NON_UNICODE, WARN_NONCHAR))
@@ -137,12 +142,9 @@ Perl_uvoffuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags)
}
}
}
- if (UNI_IS_INVARIANT(uv)) {
- *d++ = (U8) LATIN1_TO_NATIVE(uv);
- return d;
- }
+
#if defined(EBCDIC)
- else {
+ {
STRLEN len = OFFUNISKIP(uv);
U8 *p = d+len-1;
while (p > d) {