protocolbuffers / protobuf

Protocol Buffers - Google's data interchange format
http://protobuf.dev
Other
65.62k stars 15.48k forks source link

Move operation in the reflection API in C++ #19045

Open christopher-kwan-ai opened 2 days ago

christopher-kwan-ai commented 2 days ago

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 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.

sbenzaquen commented 1 day ago

There currently are no "move" operations in the reflection API. I can offer you two options:

christopher-kwan-ai commented 1 day ago

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