Skip to content

Commit

Permalink
Addressed PR comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
haberman committed Apr 20, 2021
1 parent ed708fc commit 4132034
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions upb/decode_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,41 +566,41 @@ TAGBYTES(p)
\
UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);

#define FASTDECODE_PACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \
valbytes, unpacked) \
FASTDECODE_CHECKPACKED(tagbytes, CARD_r, unpacked) \
\
ptr += tagbytes; \
int size = (uint8_t)ptr[0]; \
ptr++; \
if (size & 0x80) { \
ptr = fastdecode_longsize(ptr, &size); \
} \
\
if (UPB_UNLIKELY(fastdecode_boundscheck(ptr, size, d->limit_ptr)) || \
(size % valbytes) != 0) { \
return fastdecode_err(d); \
} \
\
upb_array **arr_p = fastdecode_fieldmem(msg, data); \
upb_array *arr = *arr_p; \
uint8_t elem_size_lg2 = __builtin_ctz(valbytes); \
int elems = size / valbytes; \
\
if (UPB_LIKELY(!arr)) { \
*arr_p = arr = _upb_array_new(&d->arena, elems, elem_size_lg2); \
if (!arr) { \
return fastdecode_err(d); \
} \
} else { \
_upb_array_resize(arr, elems, &d->arena); \
} \
\
char *dst = _upb_array_ptr(arr); \
memcpy(dst, ptr, size); \
arr->len = elems; \
\
ptr += size; \
#define FASTDECODE_PACKEDFIXED(d, ptr, msg, table, hasbits, data, tagbytes, \
valbytes, unpacked) \
FASTDECODE_CHECKPACKED(tagbytes, CARD_r, unpacked) \
\
ptr += tagbytes; \
int size = (uint8_t)ptr[0]; \
ptr++; \
if (size & 0x80) { \
ptr = fastdecode_longsize(ptr, &size); \
} \
\
if (UPB_UNLIKELY(fastdecode_boundscheck(ptr, size, d->limit_ptr) || \
(size % valbytes) != 0)) { \
return fastdecode_err(d); \
} \
\
upb_array **arr_p = fastdecode_fieldmem(msg, data); \
upb_array *arr = *arr_p; \
uint8_t elem_size_lg2 = __builtin_ctz(valbytes); \
int elems = size / valbytes; \
\
if (UPB_LIKELY(!arr)) { \
*arr_p = arr = _upb_array_new(&d->arena, elems, elem_size_lg2); \
if (!arr) { \
return fastdecode_err(d); \
} \
} else { \
_upb_array_resize(arr, elems, &d->arena); \
} \
\
char *dst = _upb_array_ptr(arr); \
memcpy(dst, ptr, size); \
arr->len = elems; \
\
ptr += size; \
UPB_MUSTTAIL return fastdecode_dispatch(UPB_PARSE_ARGS);

#define FASTDECODE_FIXED(d, ptr, msg, table, hasbits, data, tagbytes, \
Expand Down

0 comments on commit 4132034

Please sign in to comment.