You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If it's a proto syntax change, is it for proto2 or proto3?
Proto3
Describe the problem you are trying to solve.
Trying to use the reflection API in C++. My reflected proto contains a bytes field but I am not able to find a way to move the bytes out of the reflected message. It looks like the methods available only provide references.
Describe the solution you'd like
Would like to be able to move bytes out of the message, similar to how I can make a MutableMessage call or a ReleaseMessage call on nested messages.
Describe alternatives you've considered
NA
Additional context
I'm moving this bytes field into a separate proto message and would like to avoid the copy cost.
The text was updated successfully, but these errors were encountered:
There currently are no "move" operations in the reflection API.
I can offer you two options:
Reflection::SwapField to swap the field into the destination message. This only works if it is the same field on source and destination, though.
Use absl::Cord as the underlying type. This type has copy-on-write semantics so you can "get" from the source and "set" on the destination without a deep copy. See https://protobuf.dev/reference/cpp/cpp-generated/#cord
Thanks for the response. It sounds like both source and destination will need to support Cord in this case if I would like to enjoy that optimization. Any clues if the move operations will be something that is on the roadmap? Would love to see this as an available feature
What language does this apply to?
CPP
If it's a proto syntax change, is it for proto2 or proto3?
Proto3
Describe the problem you are trying to solve.
Trying to use the reflection API in C++. My reflected proto contains a
bytes
field but I am not able to find a way to move thebytes
out of the reflected message. It looks like the methods available only provide references.Describe the solution you'd like
Would like to be able to move
bytes
out of the message, similar to how I can make aMutableMessage
call or aReleaseMessage
call on nested messages.Describe alternatives you've considered
NA
Additional context
I'm moving this
bytes
field into a separate proto message and would like to avoid the copy cost.The text was updated successfully, but these errors were encountered: