summaryrefslogtreecommitdiff
path: root/src/upb_stream.c
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2011-03-21 10:44:19 -0700
committerJoshua Haberman <jhaberman@gmail.com>2011-03-21 10:44:19 -0700
commit484809c272df7b1f05e56d09f6a5e8e0f340cac4 (patch)
tree3b8c70dc4b14e68dc3e1c34024fd795b69af7715 /src/upb_stream.c
parentb796c1b31729e3e8f2501c30c0b8856f773b555c (diff)
Key dispatch table by (num x type), for modest perf improvement.
This allows us to remove one type check in the critical path.
Diffstat (limited to 'src/upb_stream.c')
-rw-r--r--src/upb_stream.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/upb_stream.c b/src/upb_stream.c
index af266dc..3b0119c 100644
--- a/src/upb_stream.c
+++ b/src/upb_stream.c
@@ -77,17 +77,16 @@ void upb_handlers_uninit(upb_handlers *h) {
static upb_handlers_fieldent *upb_handlers_getorcreate_without_fval(
upb_handlers *h, upb_field_number_t fieldnum, upb_fieldtype_t type) {
+ uint32_t tag = fieldnum << 3 | upb_types[type].native_wire_type;
upb_handlers_fieldent *f =
- upb_inttable_lookup(&h->msgent->fieldtab, fieldnum);
+ upb_inttable_lookup(&h->msgent->fieldtab, tag);
if (!f) {
- upb_wire_type_t native_wire_type = upb_types[type].native_wire_type;
- upb_handlers_fieldent new_f = {
- false, type, native_wire_type, -1, UPB_NO_VALUE,
+ upb_handlers_fieldent new_f = {false, type, -1, UPB_NO_VALUE,
{&upb_value_nop}, &upb_endsubmsg_nop};
if (upb_issubmsgtype(type)) new_f.cb.startsubmsg = &upb_startsubmsg_nop;
- upb_inttable_insert(&h->msgent->fieldtab, fieldnum, &new_f);
+ upb_inttable_insert(&h->msgent->fieldtab, tag, &new_f);
- f = upb_inttable_lookup(&h->msgent->fieldtab, fieldnum);
+ f = upb_inttable_lookup(&h->msgent->fieldtab, tag);
assert(f);
}
assert(f->type == type);
@@ -223,7 +222,7 @@ void upb_handlers_pop(upb_handlers *h, upb_fielddef *f) {
/* upb_dispatcher *************************************************************/
static upb_handlers_fieldent toplevel_f = {
- false, 0, 0, 0, // The one value that is actually read
+ false, 0, 0, // The one value that is actually read
#ifdef NDEBUG
{{0}},
#else
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback