From 1045c414b4d7fd97b9ed116dcd62f79eb087dbd9 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Tue, 30 Oct 2012 10:15:38 -0600 Subject: [PATCH] utf8.c: Remove redundant unlikely branches The 2 lines removed in each function provide an early exit if the input is malformed UTF-8. Other code executed later makes the same test. But most inputs are going to be well-formed, so the test will almost always fail, so will slow things up. --- utf8.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/utf8.c b/utf8.c index 184e429..3ee9f2d 100644 --- a/utf8.c +++ b/utf8.c @@ -383,8 +383,6 @@ Perl_is_utf8_string(const U8 *s, STRLEN len) if (UTF8_IS_INVARIANT(*x)) { x++; } - else if (!UTF8_IS_START(*x)) - return FALSE; else { /* ... and call is_utf8_char() only if really needed. */ const STRLEN c = UTF8SKIP(x); @@ -447,8 +445,6 @@ Perl_is_utf8_string_loclen(const U8 *s, STRLEN len, const U8 **ep, STRLEN *el) /* Inline the easy bits of is_utf8_char() here for speed... */ if (UTF8_IS_INVARIANT(*x)) next_char_ptr = x + 1; - else if (!UTF8_IS_START(*x)) - goto out; else { /* ... and call is_utf8_char() only if really needed. */ c = UTF8SKIP(x); -- 1.8.3.1