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:
parent
af3fbb13f6
commit
9bcf391355
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
/** Specialized list of {@link Edit}s in a document. */
|
/** Specialized list of {@link Edit}s in a document. */
|
||||||
public class EditList extends AbstractList<Edit> {
|
public class EditList extends AbstractList<Edit> {
|
||||||
|
@ -99,6 +100,11 @@ public void add(final int index, final Edit element) {
|
||||||
container.add(index, element);
|
container.add(index, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(Collection<? extends Edit> c) {
|
||||||
|
return container.addAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Edit remove(final int index) {
|
public Edit remove(final int index) {
|
||||||
return container.remove(index);
|
return container.remove(index);
|
||||||
|
|
Loading…
Reference in New Issue