Tried trivial object:

proto::TestVector tv;
tv.mutable_name()->Reserve(length);

Strange thing happens: Above code calls memcpy...
#callq  0x404e98 <mem...@plt>
even if I do not assign anything.

Good side the following was indeed converted to memcpy.

for(int i=0; i<length; ++i,++zz){
  tv.add_name(*zz);
}

but it still has 2 pages of assembler in front of it.

(g++ 4.1.2 with -O2)


On Jan 8, 1:45 pm, Vlad <vladimir.sakha...@gmail.com> wrote:
> Cool
> Will do.
> thanks
>
> On Jan 8, 12:44 pm, Kenton Varda <ken...@google.com> wrote:
>
> > On Fri, Jan 8, 2010 at 5:48 AM, Vlad <vladimir.sakha...@gmail.com> wrote:
> > > You can add mass assignment to your array operations and that would
> > > keep you design intact and complete array operation needs.
> > > It is already possible to reserve and access entire array but you can
> > > only assign one element at a time.
>
> > Just use a loop.  On any modern compiler it will be just as fast as if we
> > had provided some sort of "mass assignment" method.
>
> > > On Jan 7, 6:00 pm, Evan Jones <ev...@mit.edu> wrote:
> > > > On Jan 7, 2010, at 17:41 , Vlad wrote:
>
> > > > >  inline const ::std::string& name() const;  //problem here need
> > > > > creation of string -> very slow!
>
> > > > This doesn't create a string, it just returns a reference to the
> > > > string already in the protocol buffer object. If you do:
>
> > > > const char* c_string = protobuffer.name().data()
>
> > > > this gets a pointer to the raw C string inside the C++ string object
> > > > inside the protocol buffer object. No allocations or copies will be
> > > > performed. Setting the string, one copy is always performed, as Kenton
> > > > mentioned.
>
> > > > Evan
>
> > > > --
> > > > Evan Joneshttp://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<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.


Reply via email to