-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
17
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
In implementation of methods removeAll(Collection<?> c) and retainAll(Collection<?> c) for class AbstractCollection (and its child that override these methods) can be added checking the references equality with getting collection c. For removeAll(Collection<?> c), if references are equal, will be called method clear(), and returned true, if collection wasn't empty before clearing; for retainAll(Collection<?> c), if references are equal, will be returned true, if collection wasn't empty. I think that these optimization is useful for big size collection (skipping iteration).
In implementation of methods removeAll(Collection<?> c) and retainAll(Collection<?> c) for class AbstractCollection (and its child that override these methods) can be added checking the references equality with getting collection c. For removeAll(Collection<?> c), if references are equal, will be called method clear(), and returned true, if collection wasn't empty before clearing; for retainAll(Collection<?> c), if references are equal, will be returned true, if collection wasn't empty. I think that these optimization is useful for big size collection (skipping iteration).