diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-28 10:42:43 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-28 11:47:28 -0700 |
commit | 1ad2feb7b3d48d8bfedfdd03ee6ca4f599041476 (patch) | |
tree | d3c172ac4f3ca04585dd57d60ddf17db90b66064 /org.eclipse.jgit/src/org/eclipse/jgit/treewalk | |
parent | 9ba7bd4df452a1d005fbf770141076e901ad61d6 (diff) | |
download | jgit-1ad2feb7b3d48d8bfedfdd03ee6ca4f599041476.tar.gz jgit-1ad2feb7b3d48d8bfedfdd03ee6ca4f599041476.zip |
Remove Repository.openObject(ObjectReader, AnyObjectId)
Going through ObjectReader.openObject(AnyObjectId) is faster, but
also produces cleaner application level code. The error checking
is done inside of the openObject method, which means it can be
removed from the application code.
Change-Id: Ia927b448d128005e1640362281585023582b1a3a
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/treewalk')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java index b7f980ccaa..6ceb839bde 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/CanonicalTreeParser.java @@ -54,9 +54,8 @@ import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.FileMode; import org.eclipse.jgit.lib.MutableObjectId; import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.ObjectLoader; -import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.ObjectReader; +import org.eclipse.jgit.lib.Repository; /** Parses raw Git trees from the canonical semi-text/semi-binary format. */ public class CanonicalTreeParser extends AbstractTreeIterator { @@ -199,17 +198,7 @@ public class CanonicalTreeParser extends AbstractTreeIterator { public void reset(final Repository repo, final AnyObjectId id, final ObjectReader curs) throws IncorrectObjectTypeException, IOException { - final ObjectLoader ldr = repo.openObject(curs, id); - if (ldr == null) { - final ObjectId me = id.toObjectId(); - throw new MissingObjectException(me, Constants.TYPE_TREE); - } - final byte[] subtreeData = ldr.getCachedBytes(); - if (ldr.getType() != Constants.OBJ_TREE) { - final ObjectId me = id.toObjectId(); - throw new IncorrectObjectTypeException(me, Constants.TYPE_TREE); - } - reset(subtreeData); + reset(curs.openObject(id, Constants.OBJ_TREE).getCachedBytes()); } @Override |