Re: [protobuf] Help with basic concepts of descriptors and reflection

2010-07-16 Thread Evan Jones

On Jul 15, 2010, at 16:40 , mark.t.macdon...@googlemail.com wrote:

coutMessage1.name();
coutMessage1.GetReflection()-GetString( ref,
stabiliser.GetDescriptor()-FindFieldByName(name));


The differences between these two are HUGE. The first one is a  
compiled local variable reference (effectively). The second has to do  
some sort of table lookup. You want to use the first form if you care  
about performance.


Evan

--
Evan Jones
http://evanjones.ca/

--
You received this message because you are subscribed to the Google Groups Protocol 
Buffers group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.



[protobuf] Help with basic concepts of descriptors and reflection

2010-07-15 Thread mark.t.macdon...@googlemail.com
1. Is there anything incorrect in my understanding so far?:

* Descriptors = INTROSPECTION (querying the message structure at
runtime)
* Reflection = Introspection + MODIFYING the message structure at
runtime
* Descriptors and Reflection are implemented as C++ structures with
member functions
* These structures are shared by all instances of the same message
class

If so, I would be interested to know how several message objects can
share the same structure (underlying implementation).

2. Both the lines below print the value of the name field in Message1.
Are there big performance or other differences between how each method
gets the value?

Message Message1;
Message ref=Message1; //reference to message1

coutMessage1.name();
coutMessage1.GetReflection()-GetString( ref,
stabiliser.GetDescriptor()-FindFieldByName(name));

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.