summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-07-08 11:44:54 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-07-08 11:44:54 -0700
commitc7ee14f8ef38a8bc90c0f1db1ad47b2e06612fa3 (patch)
tree31941e0cb545149d7e07c18e75cd2004a10cdeb6
parentc208db0752461b055b4b672ae45ba0489263ef08 (diff)
Moved bounds check to the end of the loop to increase performance.
-rw-r--r--upb_parse.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/upb_parse.c b/upb_parse.c
index 3818929..3a011a6 100644
--- a/upb_parse.c
+++ b/upb_parse.c
@@ -359,11 +359,6 @@ upb_status_t upb_parse(struct upb_parse_state *restrict s, void *buf, size_t len
void *end = (char*)buf + len;
*read = 0;
while(buf < end) {
- while(s->offset >= s->top->end_offset) {
- if(s->offset != s->top->end_offset) return UPB_ERROR_BAD_SUBMESSAGE_END;
- pop_stack_frame(s);
- }
-
struct upb_tag tag;
void *bufstart = buf;
UPB_CHECK(parse_tag(&buf, end, &tag));
@@ -379,6 +374,10 @@ upb_status_t upb_parse(struct upb_parse_state *restrict s, void *buf, size_t len
size_t bytes_read = ((char*)buf - (char*)bufstart);
*read += bytes_read;
s->offset += bytes_read;
+ while(s->offset >= s->top->end_offset) {
+ if(s->offset != s->top->end_offset) return UPB_ERROR_BAD_SUBMESSAGE_END;
+ pop_stack_frame(s);
+ }
}
return UPB_STATUS_OK;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback