summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthew DeVore <matvore@gmail.com>2019-03-18 14:05:46 -0700
committerMatthew DeVore <matvore@gmail.com>2019-03-22 16:06:22 -0700
commit00523f38a19b073990239b0f837efa14197764c7 (patch)
tree5730c7737abc08182a91c1256058ce3966333d22 /org.eclipse.jgit
parent4cd954856eb8bdbe651338e7a1e3a61dd13d4fa2 (diff)
downloadjgit-00523f38a19b073990239b0f837efa14197764c7.tar.gz
jgit-00523f38a19b073990239b0f837efa14197764c7.zip
ObjectWalk: simplify tree traversal logic
Inline newTreeVisit into enterTree and call the new method pushTree. Use pushTree both for pushing children of the existing currVisit. Change-Id: I75ea37f48b2befb738a3e88bed40ac08f1df9a03 Signed-off-by: Matthew DeVore <matvore@gmail.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java29
1 files changed, 13 insertions, 16 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
index fd578da333..8f0dd9beb2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/ObjectWalk.java
@@ -385,15 +385,15 @@ public class ObjectWalk extends RevWalk {
obj = new RevTree(idBuffer);
obj.flags = SEEN;
objects.add(obj);
- return enterTree(obj);
+ return pushTree(obj);
}
if (!(obj instanceof RevTree))
throw new IncorrectObjectTypeException(obj, OBJ_TREE);
obj.flags = flags = obj.flags | SEEN;
if ((flags & UNINTERESTING) == 0)
- return enterTree(obj);
+ return pushTree(obj);
if (boundary)
- return enterTree(obj);
+ return pushTree(obj);
continue;
case TYPE_GITLINK:
@@ -426,23 +426,17 @@ public class ObjectWalk extends RevWalk {
o.flags = flags;
if ((flags & UNINTERESTING) == 0 | boundary) {
if (o instanceof RevTree) {
- tv = newTreeVisit(o);
- tv.parent = null;
- currVisit = tv;
+ // The previous while loop should have exhausted the stack
+ // of trees.
+ assert currVisit == null;
+
+ pushTree(o);
}
return o;
}
}
}
- private RevObject enterTree(RevObject obj) throws MissingObjectException,
- IncorrectObjectTypeException, IOException {
- TreeVisit tv = newTreeVisit(obj);
- tv.parent = currVisit;
- currVisit = tv;
- return obj;
- }
-
private static int findObjectId(byte[] buf, int ptr) {
// Skip over the mode and name until the NUL before the ObjectId
// can be located. Skip the NUL as the function returns.
@@ -768,7 +762,7 @@ public class ObjectWalk extends RevWalk {
}
}
- private TreeVisit newTreeVisit(RevObject obj) throws LargeObjectException,
+ private RevObject pushTree(RevObject obj) throws LargeObjectException,
MissingObjectException, IncorrectObjectTypeException, IOException {
TreeVisit tv = freeVisit;
if (tv != null) {
@@ -782,7 +776,10 @@ public class ObjectWalk extends RevWalk {
}
tv.obj = obj;
tv.buf = reader.open(obj, OBJ_TREE).getCachedBytes();
- return tv;
+ tv.parent = currVisit;
+ currVisit = tv;
+
+ return obj;
}
private void releaseTreeVisit(TreeVisit tv) {