I've now refactored the exception code to the start of the methods and shuffled some of the if else cases around a little.
Next I plan to look at: 1) remove the following from addAll(...): if (this == collection) { collection = (ArrayList)clone(); } since it is immediately followed by a call to collection.toArray() so it should be unnecessary. 2) Change the fields to firstIndex and size. In message <aanlktikt1+rekjr8h5nuk6e-ud-nhxh5wbwh2gj3+...@mail.gmail.com>, Catherine Hope writes: > > I did some analysis on what API methods access others between the RI > and Harmony (by subclassing ArrayList and adding some trace) to answer > a couple of the review points. Thanks Cath. I wonder if we can use serialization/deserialization to figure out how the RI grows the capacity of the ArrayList. Our implementation seems to grow it quite quickly. > The differences I found were: > - RI contains(Object) calls indexOf(Object), so we could also do this > to reduce the code duplication Sounds good. > - RI add(Object), add(int, Object), addAll(Collection), addAll(int, > Collection) use ensureCapacity(int) Interesting. Makes our three grow* methods seems a little excessive. > - RI remove(Object) doesn't reference indexOf(Object) and remove(int) - > though I don't think this would save anything if we changed it Agreed. -Mark.