summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-07-01 14:14:37 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-07-01 14:14:37 +0000
commit1acdb0da20c8b57ef4b35c7c1b7e0ed3fc417368 (patch)
tree44aac2ab1ba54415185ddfae6729dc7b8081a138 /utf8.c
parentd103360b8581685282078776ac5692a3521f9a95 (diff)
downloadperl-1acdb0da20c8b57ef4b35c7c1b7e0ed3fc417368.tar.gz
Small speedup by inlining the easy bits of is_utf8_char()
into is_utf8_string(). p4raw-id: //depot/perl@17392
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/utf8.c b/utf8.c
index c2818c82fa..7ee3859d08 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)