diff options
author | Joshua Haberman <joshua@reverberate.org> | 2011-04-04 00:09:14 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2011-04-04 00:09:14 -0700 |
commit | 066d1e024c27d8171667ed28ff209ec24e031aba (patch) | |
tree | a51a00ac902b8c2ae40af5a4bb4e16067d3ec729 /src/upb_msg.h | |
parent | d6cebc329bf849f527f8a46d75799222f05d852d (diff) |
Speed up parsetostruct by using type-specialized callbacks.
Diffstat (limited to 'src/upb_msg.h')
-rw-r--r-- | src/upb_msg.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/upb_msg.h b/src/upb_msg.h index 6785131..b172134 100644 --- a/src/upb_msg.h +++ b/src/upb_msg.h @@ -150,20 +150,25 @@ struct _upb_array { }; void _upb_array_free(upb_array *a, upb_fielddef *f); -INLINE upb_valueptr _upb_array_getptr(upb_array *a, upb_fielddef *f, - uint32_t elem) { +INLINE upb_valueptr _upb_array_getptrforsize(upb_array *a, size_t type_size, + uint32_t elem) { upb_valueptr p; - p._void = &a->ptr[elem * upb_types[f->type].size]; + p._void = &a->ptr[elem * type_size]; return p; } +INLINE upb_valueptr _upb_array_getptr(upb_array *a, upb_fielddef *f, + uint32_t elem) { + return _upb_array_getptrforsize(a, upb_types[f->type].size, elem); +} + upb_array *upb_array_new(void); INLINE void upb_array_unref(upb_array *a, upb_fielddef *f) { if (a && upb_atomic_unref(&a->refcount)) _upb_array_free(a, f); } -void upb_array_recycle(upb_array **arr, upb_fielddef *f); +void upb_array_recycle(upb_array **arr); INLINE uint32_t upb_array_len(upb_array *a) { return a->len; |