On 2017-11-30 23:25, Paul Sandoz wrote:

On 30 Nov 2017, at 13:00, Claes Redestad <claes.redes...@oracle.com> wrote:

Hi,

as expected this is quite a bit easier to follow. Thanks!

As any heavy use of reflection is likely to hit cached data, then heavily 
optimizing might be ill-advised here.

A simpler optimization might be to check if the class has any superclass or 
interfaces whatsoever first, since if not then publicFields == 
privateGetDeclaredField(true). This might reduce number of LinkedHashSets 
created for many trivial class hierarchies significantly for only a nominal 
increase in code complexity, and actually reduce the retained set a bit.

I am resisting the temptation to do that right now, i threw away a highly 
optimal implementation, i liked it, but you might not :-) An intermediate 
solution is to create a pre-sized Field[][] and not be as smart about that 
allocation.

Joel points out the obvious fact that the only class that doesn't have a superclass is Object, so my optimization idea wouldn't be very effective without also checking that the super class isn't Object, making it less sweet as a middle-ground option.

Any optimization should probably be done as a follow-up, anyhow. The current patch looks fine as-is to me.


Mandy is gonna take a careful look next week.

Yes, I'd not count my review as a capital-R review in this area. Too much history. :-)

/Claes

Reply via email to