RFR: 8001647: In-place methods on Collection/List (original) (raw)
Akhil Arora akhil.arora at oracle.com
Mon Dec 10 21:48:25 UTC 2012
- Previous message: RFR: 8001647: In-place methods on Collection/List
- Next message: RFR: 8001647: In-place methods on Collection/List
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Updated with yours and Alan's comments -
http://cr.openjdk.java.net/~akhil/8001647.2/webrev/
- removed null check for removeSet
- cache this.size in removeAll, replaceAll (for ArrayList, Vector and CopyOnWriteArrayList)
- calculate removeCount instead of BitCount.cardinality()
- removed unnecessary @library from test support classes
Catching IndexOOB and throwing CME in forEach/removeAll/replaceAll seems unecessary... did you have a use-case in mind where an IndexOOB can occur with these methods?
Thanks
On 12/08/2012 05:11 AM, Arne Siegel wrote:
ArrayList.java, line 1171: final boolean anyToRemove = (removeSet != null) && !removeSet.isEmpty(); As removeSet will never be null, this line can be simplified. This is a left-over from the preceding implementation (see b67).
ArrayList.java, method forEach optimizes the loop by reducing the number of heap accesses: final int size = this.size; for (int i=0; modCount == expectedModCount && i < size; i++) { ... This trick might also be introduced to methods removeAll and replaceAll. In the ListIterator implementation of ArrayList, there are various appearances of the idiom: try { ... } catch (IndexOutOfBoundsException ex) { throw new ConcurrentModificationException(); } This technique might also be used in forEach, removeAll, and replaceAll (though not likely to be of any importance). Regards Arne Siegel
- Previous message: RFR: 8001647: In-place methods on Collection/List
- Next message: RFR: 8001647: In-place methods on Collection/List
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]