Skip to content

Commit

Permalink
Cut the size of upb_LayoutItem from 12 bytes to 6.
Browse files Browse the repository at this point in the history
If we require C23 I could do this in the enum declaration.

PiperOrigin-RevId: 700728937
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Nov 27, 2024
1 parent d08b59c commit ce9071a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions upb/mini_descriptor/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ typedef enum {
kUpb_LayoutItemType_Max = kUpb_LayoutItemType_Field,
} upb_LayoutItemType;

#define kUpb_LayoutItem_IndexSentinel ((uint16_t) - 1)
#define kUpb_LayoutItem_IndexSentinel ((uint16_t)-1)

typedef struct {
// Index of the corresponding field. When this is a oneof field, the field's
// offset will be the index of the next field in a linked list.
uint16_t field_index;
uint16_t offset;
upb_FieldRep rep;
upb_LayoutItemType type;
// These two enums are stored in bytes to avoid trailing padding while
// preserving two-byte alignment.
uint8_t /* upb_FieldRep*/ rep;
uint8_t /* upb_LayoutItemType*/ type;
} upb_LayoutItem;

typedef struct {
Expand Down

0 comments on commit ce9071a

Please sign in to comment.