From 367ef9c2ffb11b32cf0cc496d91a905d9171322a Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Mon, 28 Oct 2024 18:02:11 -0700 Subject: [PATCH] Update index vs layout_index upb docs PiperOrigin-RevId: 690813728 --- upb/reflection/def.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/upb/reflection/def.hpp b/upb/reflection/def.hpp index 452ddc6e32..9475c98fcb 100644 --- a/upb/reflection/def.hpp +++ b/upb/reflection/def.hpp @@ -93,9 +93,13 @@ class FieldDefPtr { // whatever message this field belongs to. Guaranteed to be less than // f->containing_type()->field_count(). May only be accessed once the def has // been finalized. + // The index ordering here is *dependent* on the order of the fields in the + // .proto file. uint32_t index() const { return upb_FieldDef_Index(ptr_); } - // Index into msgdef->layout->fields or file->exts + // Index into msgdef->layout->fields or file->exts. + // This is the index that the MiniTable uses, and is independent of the order + // of the fields in the .proto file. uint32_t layout_index() const { return upb_FieldDef_LayoutIndex(ptr_); } // The MessageDef to which this field belongs (for extensions, the extended