From 8d1ac7a769b3fc4725537376e0e14d3b96ebbe3d Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sun, 29 May 2011 12:24:27 -0700 Subject: [PATCH] Change EditList to extend ArrayList There is no reason for this type to contain an ArrayList and try to hide the implementation. It only slows down execution by adding an extra layer of method dispatch to each invocation. Instead subclass from ArrayList. Change-Id: Ifbb9c7060c2fe3d5a7397c1aa85fbade14088637 Signed-off-by: Shawn O. Pearce --- .../src/org/eclipse/jgit/diff/EditList.java | 56 ++----------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.java index 445ff7afe..be753bee8 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/EditList.java @@ -43,12 +43,12 @@ package org.eclipse.jgit.diff; -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 { +public class EditList extends ArrayList { + private static final long serialVersionUID = 1L; + /** * Construct an edit list containing a single edit. * @@ -62,11 +62,9 @@ public class EditList extends AbstractList { return res; } - private final ArrayList container; - /** Create a new, empty edit list. */ public EditList() { - container = new ArrayList(); + super(16); } /** @@ -77,53 +75,11 @@ public class EditList extends AbstractList { * added to the list, it will be grown to support them. */ public EditList(int capacity) { - container = new ArrayList(capacity); - } - - @Override - public int size() { - return container.size(); - } - - @Override - public Edit get(final int index) { - return container.get(index); - } - - @Override - public Edit set(final int index, final Edit element) { - return container.set(index, element); - } - - @Override - public void add(final int index, final Edit element) { - container.add(index, element); - } - - @Override - public boolean addAll(Collection c) { - return container.addAll(c); - } - - @Override - public Edit remove(final int index) { - return container.remove(index); - } - - @Override - public int hashCode() { - return container.hashCode(); - } - - @Override - public boolean equals(final Object o) { - if (o instanceof EditList) - return container.equals(((EditList) o).container); - return false; + super(capacity); } @Override public String toString() { - return "EditList" + container.toString(); + return "EditList" + super.toString(); } }