Fixes to benchmark.

pull/13171/head
Joshua Haberman 15 years ago
parent 851c6a6915
commit 372c8f0487
  1. 8
      benchmarks/parsestream.upb_table.c
  2. 2
      core/upb_def.c
  3. 12
      stream/upb_decoder.c
  4. 1
      stream/upb_strstream.c

@ -17,6 +17,12 @@ static bool initialize()
upb_status status = UPB_STATUS_INIT;
upb_symtab *s = upb_symtab_new();
upb_symtab_add_descriptorproto(s);
upb_def *fds_def = upb_symtab_lookup(
s, UPB_STRLIT("google.protobuf.FileDescriptorSet"));
if (!fds_def) {
fprintf(stderr, "Couldn't load FileDescriptorSet def");
}
upb_string *fds_str = upb_strreadfile(MESSAGE_DESCRIPTOR_FILE);
if(fds_str == NULL) {
fprintf(stderr, "Couldn't read " MESSAGE_DESCRIPTOR_FILE ":"),
@ -26,8 +32,6 @@ static bool initialize()
upb_stringsrc *ssrc = upb_stringsrc_new();
upb_stringsrc_reset(ssrc, fds_str);
upb_def *fds_def = upb_symtab_lookup(
s, UPB_STRLIT("google.protobuf.FileDescriptorSet"));
upb_decoder *d = upb_decoder_new(upb_downcast_msgdef(fds_def));
upb_decoder_reset(d, upb_stringsrc_bytesrc(ssrc));

@ -384,6 +384,8 @@ static bool upb_addfield(upb_src *src, upb_msgdef *m, upb_status *status)
f->owned = true;
break;
}
default:
upb_src_skipval(src);
}
}
CHECKSRC(upb_src_eof(src));

@ -318,7 +318,9 @@ upb_fielddef *upb_decoder_getdef(upb_decoder *d)
}
// Handles the packed field case.
if(d->field) return d->field;
if(d->field) {
return d->field;
}
uint32_t key = 0;
again:
@ -457,12 +459,15 @@ bool upb_decoder_startmsg(upb_decoder *d) {
return false;
}
upb_decoder_frame *frame = d->top;
frame->msgdef = upb_downcast_msgdef(d->field->def);
if(d->field->type == UPB_TYPE(GROUP)) {
frame->end_offset = UPB_GROUP_END_OFFSET;
} else {
} else if (d->field->type == UPB_TYPE(MESSAGE)) {
frame->end_offset = upb_decoder_offset(d) + d->delimited_len;
} else {
upb_seterr(&d->src.status, UPB_STATUS_ERROR,
"Tried to startmsg a non-msg field.");
}
frame->msgdef = upb_downcast_msgdef(d->field->def);
d->field = NULL;
return true;
}
@ -485,6 +490,7 @@ bool upb_decoder_endmsg(upb_decoder *d) {
bool upb_decoder_skipval(upb_decoder *d) {
upb_strlen_t bytes_to_skip;
d->field = NULL;
switch(d->wire_type) {
case UPB_WIRE_TYPE_VARINT: {
return upb_decoder_skipv64(d);

@ -53,6 +53,7 @@ static upb_bytesrc_vtable upb_stringsrc_vtbl = {
upb_stringsrc *upb_stringsrc_new() {
upb_stringsrc *s = malloc(sizeof(*s));
s->str = NULL;
upb_bytesrc_init(&s->bytesrc, &upb_stringsrc_vtbl);
return s;
}

Loading…
Cancel
Save