Addressed PR comment.

pull/13171/head
Joshua Haberman 4 years ago
parent ed708fcd5d
commit 4132034634
  1. 70
      upb/decode_fast.c

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

Loading…
Cancel
Save