From ce9071a708ff22437ff3ebad798ab8a442b8a6f5 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 27 Nov 2024 09:41:10 -0800 Subject: [PATCH] Cut the size of upb_LayoutItem from 12 bytes to 6. If we require C23 I could do this in the enum declaration. PiperOrigin-RevId: 700728937 --- upb/mini_descriptor/decode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/upb/mini_descriptor/decode.c b/upb/mini_descriptor/decode.c index c916f98c5a85..545f40c25434 100644 --- a/upb/mini_descriptor/decode.c +++ b/upb/mini_descriptor/decode.c @@ -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 {