From 066d1e024c27d8171667ed28ff209ec24e031aba Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Mon, 4 Apr 2011 00:09:14 -0700 Subject: Speed up parsetostruct by using type-specialized callbacks. --- src/upb_msg.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/upb_msg.h') 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; -- cgit v1.2.3