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 <ev...@mit.edu> 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/
>
>

-- 
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