membrane / soa-model

Toolkit and Java API for WSDL, WADL and XML Schema.
http://www.membrane-soa.org/soa-model/
Apache License 2.0
93 stars 73 forks source link

Performance Issue: Groovy List.minus() #191

Closed ithena closed 10 years ago

ithena commented 10 years ago

The soa-model code uses the List.minus() method (listA - listB) regularly on Lists containing different kinds of SchemaComponents.

But underlying List.minus() is very inefficient when the elements do not implement the Comparable interface. List.minus() is implemented in org.codehaus.groovy.runtime.DefaultGroovyMethods by public static List minus(List self, Collection<?> removeMe)

If the List elements do not implement Comparable a RuntimeException is thrown and catched before the hashCode of the elements is used for the equality check.

(To find out the exact way this works in Groovy you can have a look at DefaultTypeTransformation.compareToWithEqualityCheck(), org.codehaus.groovy.runtim.DefaultTypeTransformation.compareEqual and org.codehaus.groovy.runtime.NumberAwareComparator)

It would be much more efficient to have all SchemaElements implement equals + hashCode