git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 3/4] Micro-optimize TreeWalk's exitSubtree implementation
Date: Thu, 21 Aug 2008 13:57:37 -0700	[thread overview]
Message-ID: <1219352258-15431-3-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1219352258-15431-2-git-send-email-spearce@spearce.org>

Rather than recomputing the min over again we can take the hint that
the prior min (the one that describes the tree we just left) must be
one that matches itself.  There may be more than one such case, as a
min could be found and match itself and later another min is found.
So we fall back into a pathCompare if we identify more than one.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/treewalk/TreeWalk.java    |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
index 6d0ef02..ef27e4e 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -722,11 +722,19 @@ void skipEntriesEqual() throws CorruptObjectException {
 		}
 	}
 
-	private void exitSubtree() throws CorruptObjectException {
+	private void exitSubtree() {
 		depth--;
 		for (int i = 0; i < trees.length; i++)
 			trees[i] = trees[i].parent;
-		currentHead = min();
+
+		AbstractTreeIterator minRef = null;
+		for (final AbstractTreeIterator t : trees) {
+			if (t.matches != t)
+				continue;
+			if (minRef == null || t.pathCompare(minRef) < 0)
+				minRef = t;
+		}
+		currentHead = minRef;
 	}
 
 	private CanonicalTreeParser parserFor(final ObjectId id)
-- 
1.6.0.112.g9c75

  reply	other threads:[~2008-08-21 20:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21 20:57 [JGIT PATCH 1/4] Simplify and micro-optimize WorkingTreeIterator.ENTRY_CMP Shawn O. Pearce
2008-08-21 20:57 ` [JGIT PATCH 2/4] Support post order tree handling during TreeWalk Shawn O. Pearce
2008-08-21 20:57   ` Shawn O. Pearce [this message]
2008-08-21 20:57     ` [JGIT PATCH 4/4] Add getNameString to TreeWalk to get only the last path component Shawn O. Pearce
2008-08-22 20:45 ` [JGIT PATCH 1/4] Simplify and micro-optimize WorkingTreeIterator.ENTRY_CMP Robin Rosenberg
2008-08-22 23:07   ` Shawn O. Pearce

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=1219352258-15431-3-git-send-email-spearce@spearce.org \
    --to=spearce@spearce.org \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg@dewire.com \
    /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).