Addressed PR comments.

pull/13171/head
Joshua Haberman 3 years ago
parent cfda119c52
commit 50b360f974
  1. 16
      upb/util/required_fields.c
  2. 2
      upb/util/required_fields.h

@ -193,13 +193,9 @@ static void upb_FindContext_Pop(upb_FindContext* ctx) {
ctx->stack.size--;
}
static void upb_util_FindUnsetRequiredInternal(upb_FindContext* ctx,
static void upb_util_FindUnsetInMessage(upb_FindContext* ctx,
const upb_msg* msg,
const upb_msgdef* m) {
// OPT: add markers in the schema for where we can avoid iterating:
// 1. messages with no required fields.
// 2. messages that cannot possibly reach any required fields.
// Iterate over all fields to see if any required fields are missing.
for (int i = 0, n = upb_msgdef_fieldcount(m); i < n; i++) {
const upb_fielddef* f = upb_msgdef_field(m, i);
@ -223,6 +219,16 @@ static void upb_util_FindUnsetRequiredInternal(upb_FindContext* ctx,
}
}
}
}
static void upb_util_FindUnsetRequiredInternal(upb_FindContext* ctx,
const upb_msg* msg,
const upb_msgdef* m) {
// OPT: add markers in the schema for where we can avoid iterating:
// 1. messages with no required fields.
// 2. messages that cannot possibly reach any required fields.
upb_util_FindUnsetInMessage(ctx, msg, m);
// Iterate over all present fields to find sub-messages that might be missing
// required fields. This may revisit some of the fields already inspected

@ -67,6 +67,8 @@ typedef union {
//
// The output buffer `buf` will always be NULL-terminated. If the output data
// (including NULL terminator) exceeds `size`, the result will be truncated.
// Returns the string length of the data we attempted to write, excluding the
// terminating NULL.
size_t upb_FieldPath_ToText(upb_FieldPathEntry **path, char *buf, size_t size);
// Checks whether `msg` or any of its children has unset required fields,

Loading…
Cancel
Save