Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Java deserialization - any best practices for performances?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Kenton Varda  
View profile  
 More options Jul 23 2009, 1:42 pm
From: Kenton Varda <ken...@google.com>
Date: Thu, 23 Jul 2009 10:42:45 -0700
Local: Thurs, Jul 23 2009 1:42 pm
Subject: Re: Java deserialization - any best practices for performances?

On Thu, Jul 23, 2009 at 12:32 AM, alopecoid <alopec...@gmail.com> wrote:

> Hi,

> I haven't actually used the Java protobuf API, but it seems to me from
> the quick occasional glance that this isn't entirely true. I mean,
> specifically in response to the code snippet posted in the original
> message, I would possibly:

> 1. Reuse the Builder object by calling its clear() method. This would
> save from the need to create a new Builder object for each iteration
> of the outermost loop.

You can't continue to use a Builder after calling build().  Even if we made
it so you could, it would be building an entirely new object, not reusing
the old one.  We can't make it reuse the old one because that would break
the immutability guarantee of message objects.

Reusing the actual builder object is not that useful since it's only a very
small object containing a pointer to a message object.

> 2. Iterate over the repeated field using the get*Count() and get*
> (index) methods instead of the get*List() method. I'm not sure if this
> would save anything, but depending on how things are implemented in
> the generated code, this could save from allocating a new List object.

Won't save anything; we still need a list object internally.

But seriously, object allocation with a modern generational garbage
collector is extremely cheap, especially for objects that don't stick around
very long.  So I don't think there's much to gain here.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.