From 0d791659e1150154404bf311bf706063b65303e8 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 6 Jan 2009 00:00:21 +0000 Subject: Dubious optimisation I've had sitting around for ages. svn path=/trunk/libparserutils/; revision=5963 --- include/parserutils/input/inputstream.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/parserutils/input/inputstream.h') diff --git a/include/parserutils/input/inputstream.h b/include/parserutils/input/inputstream.h index fefc0ce..dac1ab7 100644 --- a/include/parserutils/input/inputstream.h +++ b/include/parserutils/input/inputstream.h @@ -110,8 +110,10 @@ static inline uintptr_t parserutils_inputstream_peek( #define IS_ASCII(x) (((x) & 0x80) == 0) if (off < utf8_len) { - if (IS_ASCII(utf8->data[off])) { - len = 1; + if (IS_ASCII(utf8_data[off])) { + /* Early exit for ASCII case */ + (*length) = 1; + return (uintptr_t) (utf8_data + off); } else { error = parserutils_charset_utf8_char_byte_length( utf8_data + off, &len); -- cgit v1.2.3