Map fields - accessing directly, versus with reflection

28 views
Skip to first unread message

cullenskink52

unread,
Jun 14, 2024, 5:38:25 PMJun 14
to Protocol Buffers

Hey -
Can I confirm a piece of understanding about map fields?
I was traversing some message instances with map fields in C++, and it seems:

- if I traverse using known message types - for example get my_message.my_map_field() as a protobuf::Map<k,v>, and traverse the key value pairs inside there, I am dealing with the original data 'as is', and 'in situ'. So if the value type is a message, I'll find the address I get in the key value pair is the address of the message in the original context

- if I traverse using reflection, without knowing types or field names, I will have to call GetRepeatedField() to get the contents of the field; and critically, when I do that, the reflection API will generate temporaries representing the contents? So once I find the value message, it will NOT be in situ in the original message?

Do I have that correct?

All/any thoughts much appreciated. 
Reply all
Reply to author
Forward
0 new messages