From: Jarkko Hietaniemi Date: Mon, 1 Jul 2002 14:14:37 +0000 (+0000) Subject: Small speedup by inlining the easy bits of is_utf8_char() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1acdb0da20c8b57ef4b35c7c1b7e0ed3fc417368;p=p5sagit%2Fp5-mst-13.2.git Small speedup by inlining the easy bits of is_utf8_char() into is_utf8_string(). p4raw-id: //depot/perl@17392 --- diff --git a/utf8.c b/utf8.c index c2818c8..7ee3859 100644 --- a/utf8.c +++ b/utf8.c @@ -237,9 +237,17 @@ Perl_is_utf8_string(pTHX_ U8 *s, STRLEN len) send = s + len; while (x < send) { - c = is_utf8_char(x); - if (!c) - return FALSE; + /* Inline the easy bits of is_utf8_char() here for speed... */ + if (UTF8_IS_INVARIANT(*x)) + c = 1; + else if (!UTF8_IS_START(*x)) + return FALSE; + else { + /* ... and call is_utf8_char() only if really needed. */ + c = is_utf8_char(x); + if (!c) + return FALSE; + } x += c; } if (x != send)