Skip to main content



      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 11:18 Go to next message
Eclipse UserFriend
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 11:24 Go to previous message
Eclipse UserFriend
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: Mon May 19 17:17:32 EDT 2025

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

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

Back to the top