Optimizes `upb_MiniTable_Enum` for enums with many values (>64) but with relatively dense packing in numeric space.
This CL optimizes both the size and speed of such enums:
- size: 30x code size reduction
- speed: moved from linear search to a constant-time bit test
Negative enum values are still expensive, as they are never put into the bitfield.
PiperOrigin-RevId: 473259819
Instead of bounds-testing a double value to guess whether it will overflow,
just convert it to a float and check whether the result is +/- infinity.
PiperOrigin-RevId: 472811865
The functions declared in reflection.h use neither arrays nor maps, so (a) stop including the array and map definitions, and (b) update the handful of other source files which were relying on that transitivity.
PiperOrigin-RevId: 472627278
This is a naming change only, with no functional change. We did replace one inline function that had only one caller, but the net effect should be a no-op.
I did remove several `return` statements for calls to certain `noreturn` functions. These had no effect but were intended to improve readability. However the unused "return" caused ClangTidy to throw warnings, so these have been removed.
PiperOrigin-RevId: 472619191
- opt_default is now kUpbDefOptDefault
- upb_AddDefCtx is now upb_DefBuilder
- shortdefname() is now _upb_DefBuilder_FullToShort()
- pack_def() is now _upb_DefBuilder_Pack()
- unpack_def() is now _upb_DefBuilder_Unpack()
- UPB_ASSERT() checks on def struct size moved up in the call chain
- remove/expand CHK_OOM
PiperOrigin-RevId: 471862679
(Because it is a better name and we can't properly bikeshed it without changing
it a few times first.)
Also removed it as an arg from a function that doesn't actually need it.
PiperOrigin-RevId: 470978322
- check_ident() is now _upb_AddDefCtx_CheckIdent()
- makefullname() is now _upb_AddDefCtx_MakeFullName()
- symtab_add() is now _upb_AddDefCtx_Add()
- symtab_alloc() is now _upb_AddDefCtx_Alloc()
- symtab_errf() is now _upb_AddDefCtx_Errf()
- symtab_oomerr() is now _upb_AddDefCtx_OomErr()
PiperOrigin-RevId: 470806376
- renamed symtab_addctx as upb_AddDefCtx
- simplified _upb_DefPool_AddFile() slightly
- replaced upb_Status_setoom() with kOutOfMemory
- deleted all references to UPB_DEFTYPE_LAYOUT and UPB_DEFTYPE_FILE
PiperOrigin-RevId: 470592649
This function was introduced in https://github.com/protocolbuffers/upb/pull/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: 470567000
There are many places within def.c where a function which implements a method
for struct A ends up directly accessing fields within struct B even though
accessor functions for these fields are defined. So, this is a first pass at
trying to clean that up a bit. Yes, we are adding function calls to a lot of
code paths by doing this but in the unlikely event that this adds unacceptable
overhead we can deal with it then.
PiperOrigin-RevId: 470321129
Give the def types their own array allocators and also implement some simple array constructors for the enum and enum value defs.
PiperOrigin-RevId: 470042521
upb_String is a hack which exists because the original C++ tokenizer got to
assume the existence of C++ strings, so at least for now the C tokenizer needs
a rough equivalent. But this should be a purely internal implementation detail,
not part of the visible surface.
PiperOrigin-RevId: 469814074
- Disallow multiline strings.
- Disallow a letter immediately following a number without intervening whitespace.
- Replace distinct bool option flags with a single options int.
PiperOrigin-RevId: 467829817
delete upb_EnumDef_IsSorted()
We now have a simple internal function for returning a mini descriptor directly from an enum def.
PiperOrigin-RevId: 461208352
1. upb now tolerates a present-but-empty package name in a `FileDescriptorProto`.
2. upb now always returns a non-NULL string for `upb_FileDef_Package()`. If the package was empty or missing, the returned string is zero-length. This better matches the proto2 behavior: `proto2::FileDescriptor::package()` always returns a package string, which may be empty.
PiperOrigin-RevId: 460831797
- Correctly set the modifier field for MessageDefs
- Add error handling
- Respect the provided arena, stop hardwiring the global alloc
- upb_MiniDescriptor_EncodeExtension() is now upb_MiniDescriptor_EncodeField()
- Make the plugin code a lot easier to read
PiperOrigin-RevId: 460482002
Internal array functions are now implemented in upb/internal/array.c and declared in
upb/internal/array.h, which only has local visibility.
PiperOrigin-RevId: 458260144
some headers were not including port_def.inc
some headers were not declaring extern "C"
some headers were backing out of the above in the wrong order
PiperOrigin-RevId: 457391878