Skip to content

Commit

Permalink
Removed unused _upb_DefPool_registerlayout() function.
Browse files Browse the repository at this point in the history
This function was introduced in #426 but it appears it was never used.  I am not sure what the purpose was, but in any case it is not needed.

With this function removed, we no longer need to tag pointers for the DefPool "files" table.

PiperOrigin-RevId: 470565730
  • Loading branch information
haberman authored and copybara-github committed Aug 28, 2022
1 parent 11aa037 commit 3847f6d
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions upb/def.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ typedef enum {

/* Only inside file table. */
UPB_DEFTYPE_FILE = 0,
UPB_DEFTYPE_LAYOUT = 1
} upb_deftype_t;

#define FIELD_TYPE_UNSPECIFIED 0
Expand Down Expand Up @@ -1233,17 +1232,16 @@ const upb_EnumValueDef* upb_DefPool_FindEnumByNameval(const upb_DefPool* s,
const upb_FileDef* upb_DefPool_FindFileByName(const upb_DefPool* s,
const char* name) {
upb_value v;
return upb_strtable_lookup(&s->files, name, &v)
? unpack_def(v, UPB_DEFTYPE_FILE)
: NULL;
return upb_strtable_lookup(&s->files, name, &v) ? upb_value_getconstptr(v)
: NULL;
}

const upb_FileDef* upb_DefPool_FindFileByNameWithSize(const upb_DefPool* s,
const char* name,
size_t len) {
upb_value v;
return upb_strtable_lookup2(&s->files, name, len, &v)
? unpack_def(v, UPB_DEFTYPE_FILE)
? upb_value_getconstptr(v)
: NULL;
}

Expand Down Expand Up @@ -3124,20 +3122,9 @@ static const upb_FileDef* _upb_DefPool_AddFile(
upb_value v;

if (upb_strtable_lookup2(&s->files, name.data, name.size, &v)) {
if (unpack_def(v, UPB_DEFTYPE_FILE)) {
upb_Status_SetErrorFormat(status, "duplicate file name (%.*s)",
UPB_STRINGVIEW_ARGS(name));
return NULL;
}
const upb_MiniTable_File* registered = unpack_def(v, UPB_DEFTYPE_LAYOUT);
UPB_ASSERT(registered);
if (layout && layout != registered) {
upb_Status_SetErrorFormat(
status, "tried to build with a different layout (filename=%.*s)",
UPB_STRINGVIEW_ARGS(name));
return NULL;
}
layout = registered;
upb_Status_SetErrorFormat(status, "duplicate file name (%.*s)",
UPB_STRINGVIEW_ARGS(name));
return NULL;
}

ctx.symtab = s;
Expand Down Expand Up @@ -3167,7 +3154,7 @@ static const upb_FileDef* _upb_DefPool_AddFile(
ctx.file = _upb_FileDef_Alloc(&ctx);
build_filedef(&ctx, ctx.file, file_proto);
upb_strtable_insert(&s->files, name.data, name.size,
pack_def(ctx.file, UPB_DEFTYPE_FILE), ctx.arena);
upb_value_constptr(ctx.file), ctx.arena);
UPB_ASSERT(upb_Status_IsOk(status));
upb_Arena_Fuse(s->arena, ctx.arena);
}
Expand Down Expand Up @@ -3260,14 +3247,6 @@ const upb_FieldDef* upb_DefPool_FindExtensionByNumber(const upb_DefPool* s,
return ext ? _upb_DefPool_FindExtensionByMiniTable(s, ext) : NULL;
}

bool _upb_DefPool_registerlayout(upb_DefPool* s, const char* filename,
const upb_MiniTable_File* file) {
if (upb_DefPool_FindFileByName(s, filename)) return false;
upb_value v = pack_def(file, UPB_DEFTYPE_LAYOUT);
return upb_strtable_insert(&s->files, filename, strlen(filename), v,
s->arena);
}

const upb_ExtensionRegistry* upb_DefPool_ExtensionRegistry(
const upb_DefPool* s) {
return s->extreg;
Expand Down

0 comments on commit 3847f6d

Please sign in to comment.