From 979f77b669f1feffa864bb57c9d95ac3cf12481c Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 28 Apr 2012 18:40:40 -0600 Subject: [PATCH] utf8.c: Extra branch to avoid others in the typical case This test eliminates all code points less than U+D800 from having to be checked more than once, at the expense of an extra test for code points that are larger --- utf8.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utf8.c b/utf8.c index 83d239735e..ce0820dc9a 100644 --- a/utf8.c +++ b/utf8.c @@ -137,7 +137,10 @@ Perl_uvuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags) { PERL_ARGS_ASSERT_UVUNI_TO_UTF8_FLAGS; - if (ckWARN4_d(WARN_UTF8, WARN_SURROGATE, WARN_NON_UNICODE, WARN_NONCHAR)) { + /* 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)) + { if (UNICODE_IS_SURROGATE(uv)) { if (flags & UNICODE_WARN_SURROGATE) { Perl_ck_warner_d(aTHX_ packWARN(WARN_SURROGATE),