Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: 3.0
-
Component/s: groovy-jdk
-
Labels:None
-
Number of attachments :
Description
org.codehaus.groovy.runtime.DefaultGroovyMethods#minus(Set<T> self, Collection<?> removeMe)'s complexity is O(m*n). If you used something like THashSet (http://trove4j.sourceforge.net/javadocs/gnu/trove/set/hash/THashSet.html) you could make it O(m+n) by plugging in a smart hashing strategy. Perhaps you already have something similar in your codebase or dependencies?
The problem is that we want to keep the order of the elements as well if you for example do the call on a LinkedHashSet. Any kind of hashing on our side that does not keep the order would thus destroy the order. Also our test for the elements to be unique or not depends on a Groovy compare, thus we have to handle for example arrays and list at the same time or simply Comparable. I don't know how such a hashing method would look like for Comparable. We would also have to do our own structure, since we would need to know if the element has been added in the end or not.