git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [JGIT PATCH 1/4] Simplify and micro-optimize WorkingTreeIterator.ENTRY_CMP
@ 2008-08-21 20:57 Shawn O. Pearce
  2008-08-21 20:57 ` [JGIT PATCH 2/4] Support post order tree handling during TreeWalk Shawn O. Pearce
  2008-08-22 20:45 ` [JGIT PATCH 1/4] Simplify and micro-optimize WorkingTreeIterator.ENTRY_CMP Robin Rosenberg
  0 siblings, 2 replies; 6+ messages in thread
From: Shawn O. Pearce @ 2008-08-21 20:57 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: git

We already did this simplification work to AbstractTreeIterator's
pathCompare method, and this is based upon that same structure.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../spearce/jgit/treewalk/WorkingTreeIterator.java |   44 ++-----------------
 1 files changed, 5 insertions(+), 39 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
index c6664f5..6fce150 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
@@ -297,45 +297,11 @@ public int compare(final Entry o1, final Entry o2) {
 					return cmp;
 			}
 
-			if (cPos < aLen) {
-				final int aj = a[cPos] & 0xff;
-				final int lastb = lastPathChar(o2);
-				if (aj < lastb)
-					return -1;
-				else if (aj > lastb)
-					return 1;
-				else if (cPos == aLen - 1)
-					return 0;
-				else
-					return -1;
-			}
-
-			if (cPos < bLen) {
-				final int bk = b[cPos] & 0xff;
-				final int lasta = lastPathChar(o1);
-				if (lasta < bk)
-					return -1;
-				else if (lasta > bk)
-					return 1;
-				else if (cPos == bLen - 1)
-					return 0;
-				else
-					return 1;
-			}
-
-			final int lasta = lastPathChar(o1);
-			final int lastb = lastPathChar(o2);
-			if (lasta < lastb)
-				return -1;
-			else if (lasta > lastb)
-				return 1;
-
-			if (aLen == bLen)
-				return 0;
-			else if (aLen < bLen)
-				return -1;
-			else
-				return 1;
+			if (cPos < aLen)
+				return (a[cPos] & 0xff) - lastPathChar(o2);
+			if (cPos < bLen)
+				return lastPathChar(o1) - (b[cPos] & 0xff);
+			return lastPathChar(o1) - lastPathChar(o2);
 		}
 	};
 
-- 
1.6.0.112.g9c75

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-08-22 23:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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   ` [JGIT PATCH 3/4] Micro-optimize TreeWalk's exitSubtree implementation Shawn O. Pearce
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

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).