[PATCH JGIT] Make it possible to clear a PlotCommitList

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows SwingGraphPanes to be reused by simply clearing and
re-filling. Requires RevObjectList initialization to not call clear()
from its constructor, because this will lead PlotCommitList.clear() to
be called before all variables have been initialized.

Signed-off-by: Jonas Fonseca <fonseca@xxxxxxx>
---
 .../org/spearce/jgit/revplot/PlotCommitList.java   |   12 ++++++++++--
 .../org/spearce/jgit/revwalk/RevObjectList.java    |    7 +++----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/revplot/PlotCommitList.java b/org.spearce.jgit/src/org/spearce/jgit/revplot/PlotCommitList.java
index a0959e2..39e4759 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revplot/PlotCommitList.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revplot/PlotCommitList.java
@@ -64,7 +64,15 @@
 
 	private final TreeSet<Integer> freeLanes = new TreeSet<Integer>();
 
-	private HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32);
+	private final HashSet<PlotLane> activeLanes = new HashSet<PlotLane>(32);
+
+	@Override
+	public void clear() {
+		super.clear();
+		lanesAllocated = 0;
+		freeLanes.clear();
+		activeLanes.clear();
+	}
 
 	@Override
 	public void source(final RevWalk w) {
@@ -133,7 +141,7 @@ protected void enter(final int index, final PlotCommit<L> currCommit) {
 				final PlotCommit c = currCommit.children[i];
 				if (activeLanes.remove(c.lane)) {
 					recycleLane((L) c.lane);
-					freeLanes.add(Integer.valueOf(c.lane.position));
+					freeLanes.add(Integer.valueOf(c.lane.getPosition()));
 				}
 			}
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObjectList.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObjectList.java
index b95b127..d57c779 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObjectList.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/RevObjectList.java
@@ -50,13 +50,12 @@
 
 	static final int BLOCK_SIZE = 1 << BLOCK_SHIFT;
 
-	Block contents;
+	protected Block contents = new Block(0);
 
-	int size;
+	protected int size = 0;
 
 	/** Create an empty object list. */
 	public RevObjectList() {
-		clear();
 	}
 
 	public void add(final int index, final E element) {
@@ -107,7 +106,7 @@ public void clear() {
 		size = 0;
 	}
 
-	static class Block {
+	protected static class Block {
 		final Object[] contents = new Object[BLOCK_SIZE];
 
 		final int shift;
-- 
1.6.5.rc0.164.g5f6b0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]