-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
8, 9
A DESCRIPTION OF THE REQUEST :
Add to the beginning of the function: disjoint(Collection<?> c1, Collection<?> c2)
if(c1 == c2) return false; // same collection. All match
if (c1.isEmpty() || c2.isEmpty()) return true; // At least one collection is empty. Nothing will match.
JUSTIFICATION :
This small minor changes will easily improve run-time.
Specially for the case of (c1 instanceof Set) && (c1.isEmpty()), where we save unnecessary O(c2.size()) iterations
Add to the beginning of the function: disjoint(Collection<?> c1, Collection<?> c2)
if(c1 == c2) return false; // same collection. All match
if (c1.isEmpty() || c2.isEmpty()) return true; // At least one collection is empty. Nothing will match.
JUSTIFICATION :
This small minor changes will easily improve run-time.
Specially for the case of (c1 instanceof Set) && (c1.isEmpty()), where we save unnecessary O(c2.size()) iterations
- relates to
-
JDK-6394757 (coll) AbstractSet.removeAll semantics are surprisingly dependent on relative sizes
-
- Open
-