Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.5, 1.5.1
-
Component/s: groovy-jdk
-
Labels:None
-
Patch Submitted:Yes
-
Number of attachments :
Description
In DefaultGroovyMethods.java, a NumberAwareComparator mimics the groovy '==' operator to compare elements against each other for collections operations such as unique(), minus(), sort() etc.
This NumberAwareComparator systematically converts any number to BigDecimal if numbers are involved slowing down very significantly those operations.
By testing first if the elements are comparable and of the same 'kind' to first compareTo() them, we get a cheap but noticeable boost.
I did not apply the patch, instead I used DefaultTypeTransformation.compareTo as base for the new implementation, which has a higher performance than the bigDecimal based widening for numbers we had before.