[concurrency-interest] Review for CR 6728865 : Improved heuristics for Collections.disjoint()
forax at univ-mlv.fr
Fri Dec 17 20:02:32 EST 2010
On 12/18/2010 01:31 AM, Mike Duigou wrote:
> I've posted a webrev for review at
> which improves the behaviour of Collections.disjoint() when the collection c1 is not a Set and is larger than c2.
> I've included some other micro-optimizations suggested by the issue and by common usage.
> One optimization, the checks whether either collection is empty using isEmpty(), may slightly degrade performance relative to the current implementation but should be a good tradeoff for cases where either of the collections are empty.
> I've also upgraded the javadoc to newer style conventions and included the missing @return.
> Any comments or feedback welcome.
I think that comparing size() is not a good idea because
- for some collections, size() is not a constant operation
- you compare size() when c1 and c2 are sets which
may cause a performance regression because
disjoint(treeSet, hashSet) has not the same complexity as
Otherwise, you declare some local variables final.
Declaring a local variable as final doesn't appear in the generated
The usual convention for the source of the JDK is to use final
in front of a local variable only when needed (inner class).
PS: I have also CC JSR 166 list mailing list because I know that Doug
maintains patches for package java.util.
More information about the Concurrency-interest