Protobuf messages store strings in std::string objects. Sorry, there's no way around that. The problem with direct pointers is that you have ownership issues -- what if the data pointed to is modified or free()d while the message still exists? Making a defensive copy is not that expensive and avoids lots of bugs.
On Thu, Jan 7, 2010 at 2:41 PM, Vlad <vladimir.sakha...@gmail.com> wrote: > There is an overhead in creating string object from the message. > It is more faster to obtain direct pointer to the data and length of > it. > > inline bool has_name() const; > inline void clear_name(); > static const int kNameFieldNumber = 1; > inline void set_name(const ::std::string& value); > inline void set_name(const char* value); > inline void set_name(const char* value, size_t size); > > > So it will look instead of: > inline const ::std::string& name() const; //problem here need > creation of string -> very slow! > Something like: > inline const char* name() const; //zero copy > inline int size_name() const; //size information. > > > There is possilility to copy string one by one character but it is > even worse :( > > Regards \/. > > -- > 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<protobuf%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > > >--
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.