git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH JGIT] Make it possible to clear a PlotCommitList
@ 2009-09-20 13:34 Jonas Fonseca
  0 siblings, 0 replies; only message in thread
From: Jonas Fonseca @ 2009-09-20 13:34 UTC (permalink / raw)
  To: Robin Rosenberg, Shawn O. Pearce; +Cc: git

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@diku.dk>
---
 .../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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-09-20 13:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-20 13:34 [PATCH JGIT] Make it possible to clear a PlotCommitList Jonas Fonseca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).