From e3905b425abb872bdab1a51bd274eec30f7867b5 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 22 Jun 2009 12:42:15 -0700 Subject: Simplified the varint-skipping function. --- upb_parse.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/upb_parse.c b/upb_parse.c index b13ca24..d9e9485 100644 --- a/upb_parse.c +++ b/upb_parse.c @@ -4,7 +4,6 @@ * Copyright (c) 2008-2009 Joshua Haberman. See LICENSE for details. */ -#define INLINE #include "upb_parse.h" #include @@ -56,22 +55,11 @@ done: static upb_status_t skip_v_uint64_t(void **buf) { - uint8_t *ptr = *buf, b; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; - b = *(ptr++); if (!(b & 0x80)) goto done; + for(int i = 0; i < 10; i++, *buf++) { + uint8_t *b = *buf; + if(!(*b & 0x80)) return UPB_STATUS_OK; + } return UPB_ERROR_UNTERMINATED_VARINT; - -done: - *buf = (uint8_t*)ptr; - return UPB_STATUS_OK; } static upb_status_t get_v_uint32_t(void *restrict *buf, -- cgit v1.2.3