git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Fonseca <fonseca@diku.dk>
To: Robin Rosenberg <robin.rosenberg@dewire.com>,
	"Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: [PATCH JGIT] Make it possible to clear a PlotCommitList
Date: Sun, 20 Sep 2009 09:34:37 -0400	[thread overview]
Message-ID: <1253453677-10126-1-git-send-email-fonseca@diku.dk> (raw)

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

                 reply	other threads:[~2009-09-20 13:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1253453677-10126-1-git-send-email-fonseca@diku.dk \
    --to=fonseca@diku.dk \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg@dewire.com \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).