Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Equals/HashCode Generator sorting fields(first check primitive fiels to have early-out)
Equals/HashCode Generator sorting fields [message #959255] Fri, 26 October 2012 15:18 Go to next message
Andre Albert is currently offline Andre Albert
Messages: 25
Registered: July 2009
Junior Member
When running the eclipse Hash/Equals Generator, it looks like the relevant fields are sorted alphabetically in the code.
I guess that it would be nicer when the code first checks primitive types (java.lang) then complex types, and then arrays (or Iterables - if possible).
This might help to avoid deep tree traversals when first checking an equal complex field type before checking the (for example) name field value of the object that does not match.

This might help improving the performance for applications with a lot of "contains"-operations and big tree-like objects
Re: Equals/HashCode Generator sorting fields [message #961761 is a reply to message #959255] Sun, 28 October 2012 15:24 Go to previous message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 1007
Registered: July 2009
Senior Member
Andre Albert wrote on Fri, 26 October 2012 17:18

I guess that it would be nicer [...]
This might help to avoid deep tree traversals when first checking an equal complex field type before checking the (for example) name field value of the object that does not match.

This might help improving the performance for applications with a lot of "contains"-operations and big tree-like objects


Do you have any performance figures backing this claim? Otherwise it sounds a bit like speculative optimization, s.t. JDT should not get involved with, IMO.

Think of it this way: what are the odds that a big tree-like object structure is infact equal while a direct field (like "name") differs? If all criteria must be fulfilled for "equals", do you know which comparisons are more likely to allow an early "return false"?

best,
Stephan

Previous Topic:How to find out how is Tomcat started in Eclipse?
Next Topic:Weird Java editor behaviour
Goto Forum:
  


Current Time: Wed Oct 01 18:27:32 GMT 2014

Powered by FUDForum. Page generated in 0.12619 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software