Micro-optimize EditList.addAll

Pass through the addAll request to our underlying ArrayList.

This way the underlying ArrayList grows no more than once during the
call, which may be important if the list was originally allocated
at the default size of 16, but 64 Edits are being added.

Change-Id: I31c3261e895766f82c3c832b251a09f6e37e8860
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2010-09-21 08:23:12 -07:00
parent af3fbb13f6
commit 9bcf391355
1 changed files with 6 additions and 0 deletions

View File

@ -45,6 +45,7 @@
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
/** Specialized list of {@link Edit}s in a document. */
public class EditList extends AbstractList<Edit> {
@ -99,6 +100,11 @@ public void add(final int index, final Edit element) {
container.add(index, element);
}
@Override
public boolean addAll(Collection<? extends Edit> c) {
return container.addAll(c);
}
@Override
public Edit remove(final int index) {
return container.remove(index);