I'm also looking for proper ways to set initial capacity for my
repeatable fields (in protobuf java 2.3.0). Is this possible without
hacking the generated code?

Regards,
Prakash

On Jul 1, 3:09 am, Josh Hartman <[email protected]> wrote:
> Good catch. This was the problem and the fix results in a speedup of about
> 70% all the way from serializing 1000 elements to 1,000,000 elements in an
> int array. I'll throw my changes up on github this evening.
>
> Instead of doing an empty check, I just do a reference check against
> Collections.EMPTY_LIST.
>
> Thanks,
> Josh
>
>
>
> On Wed, Jun 30, 2010 at 2:24 PM, Evan Jones <[email protected]> wrote:
> > On Jun 29, 2010, at 17:49 , Josh Hartman wrote:
>
> >>        "public Builder ensure$capitalized_name$Capacity(int minCapacity)
> >> {\n"
> >>        "  if (result.$name$_.isEmpty()) {\n"
> >>        "    result.$name$_ = new
> >> java.util.ArrayList<$boxed_type$>(minCapacity);\n"
>
> > I think the problem is that in the empty case, the next call to add* will
> > re-create the ArrayList as empty, which defeats the call to ensureCapacity.
> > Try hacking something in that method to make this work (check the type?)
>
> > Evan
>
> > --
> > Evan Jones
> >http://evanjones.ca/- Hide quoted text -
>
> - Show quoted text -

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

Reply via email to