summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-12-01 11:51:10 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-12-01 11:51:10 +0000
commit6fe235668e49b9bddff568e0df5ce8797c57201b (patch)
tree3e4a97bc79669e4451010108e17410924c3b73fd
parentce2b034ae9dcad49d8c2721494830c3731a60ff8 (diff)
downloadlibparserutils-6fe235668e49b9bddff568e0df5ce8797c57201b.tar.gz
libparserutils-6fe235668e49b9bddff568e0df5ce8797c57201b.tar.bz2
Use temporary variables rather than indirecting through pointers all the time.
svn path=/trunk/libparserutils/; revision=5861
-rw-r--r--include/parserutils/input/inputstream.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/include/parserutils/input/inputstream.h b/include/parserutils/input/inputstream.h
index bf1911d..fefc0ce 100644
--- a/include/parserutils/input/inputstream.h
+++ b/include/parserutils/input/inputstream.h
@@ -85,7 +85,9 @@ static inline uintptr_t parserutils_inputstream_peek(
parserutils_inputstream *stream, size_t offset, size_t *length)
{
parserutils_error error = PARSERUTILS_OK;
- size_t len;
+ const parserutils_buffer *utf8;
+ const uint8_t *utf8_data;
+ size_t len, off, utf8_len;
if (stream == NULL)
return PARSERUTILS_INPUTSTREAM_OOD;
@@ -100,15 +102,19 @@ static inline uintptr_t parserutils_inputstream_peek(
#endif
#endif
+ utf8 = stream->utf8;
+ utf8_data = utf8->data;
+ utf8_len = utf8->length;
+ off = stream->cursor + offset;
+
#define IS_ASCII(x) (((x) & 0x80) == 0)
- if (stream->cursor + offset < stream->utf8->length) {
- if (IS_ASCII(stream->utf8->data[stream->cursor + offset])) {
+ if (off < utf8_len) {
+ if (IS_ASCII(utf8->data[off])) {
len = 1;
} else {
error = parserutils_charset_utf8_char_byte_length(
- stream->utf8->data + stream->cursor + offset,
- &len);
+ utf8_data + off, &len);
if (error != PARSERUTILS_OK &&
error != PARSERUTILS_NEEDDATA)
@@ -118,8 +124,7 @@ static inline uintptr_t parserutils_inputstream_peek(
#undef IS_ASCII
- if (stream->cursor + offset == stream->utf8->length ||
- error == PARSERUTILS_NEEDDATA) {
+ if (off == utf8_len || error == PARSERUTILS_NEEDDATA) {
uintptr_t data = parserutils_inputstream_peek_slow(stream,
offset, length);
#if !defined(NDEBUG) && defined(VERBOSE_INPUTSTREAM)
@@ -134,7 +139,7 @@ static inline uintptr_t parserutils_inputstream_peek(
*length = len;
- return (uintptr_t) (stream->utf8->data + stream->cursor + offset);
+ return (uintptr_t) (utf8_data + off);
}
/**