diff options
author | Joshua Haberman <joshua@ubuntu32.(none)> | 2009-06-22 12:42:15 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@ubuntu32.(none)> | 2009-06-22 12:42:15 -0700 |
commit | e3905b425abb872bdab1a51bd274eec30f7867b5 (patch) | |
tree | 5c6a6d4039997ccc533d08442a74557451be6578 | |
parent | 0124bfd8fe87cb38fe367478d18f449edce8a0ae (diff) |
Simplified the varint-skipping function.
-rw-r--r-- | upb_parse.c | 20 |
1 files 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 <assert.h> @@ -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, |