On Wed, Oct 23, 2013 at 8:01 AM, Ivan L <[email protected]> wrote:

> I have a code like:
>
>
> TestMessage* output;
> ::google::protobuf::Message* input;
> auto reflection = output->GetReflection();
>
> ...
> auto extension_field = input->GetDescriptor->extension(i);
> ...
>
> auto output_field =
> reflection->FindKnownExtensionByName(extension_field->full_name());
> reflection->MutableMessage(output, output_field)->CopyFrom(*input);
>
>
> How can I do a setting of preallocated `input` without copying - in last
> statement?
>
You can use Swap() rather than CopyFrom() to avoid the copy.


>  --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to