[EGIT PATCH 09/11] Expose idBuffer,idOffset in AbstractTreeIterator to applications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Application code needs to be able to efficiently copy an id from
an iterator's current position to some buffer, such as in the
index file or a tree object, or any other data structure.  Doing
a conversion to ObjectId and then back again to the raw byte form
is less efficient than just copying the bytes between two arrays.

So these methods must be public for performance reasons, even if
it makes the object API slightly more obtuse.  Besides we still
have getEntryObjectId should applications prefer that approach
and they don't need the performance.

Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx>
---
 .../jgit/treewalk/AbstractTreeIterator.java        |    4 ++--
 .../spearce/jgit/treewalk/CanonicalTreeParser.java |    4 ++--
 .../spearce/jgit/treewalk/EmptyTreeIterator.java   |    4 ++--
 .../spearce/jgit/treewalk/WorkingTreeIterator.java |    4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
index cf67836..6d7159c 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
@@ -321,7 +321,7 @@ public abstract class AbstractTreeIterator {
 	 * @return byte array the implementation stores object IDs within.
 	 * @see #getEntryObjectId()
 	 */
-	protected abstract byte[] idBuffer();
+	public abstract byte[] idBuffer();
 
 	/**
 	 * Get the position within {@link #idBuffer()} of this entry's ObjectId.
@@ -329,7 +329,7 @@ public abstract class AbstractTreeIterator {
 	 * @return offset into the array returned by {@link #idBuffer()} where the
 	 *         ObjectId must be copied out of.
 	 */
-	protected abstract int idOffset();
+	public abstract int idOffset();
 
 	/**
 	 * Create a new iterator for the current entry's subtree.
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
index 56bcab0..55942ed 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
@@ -112,12 +112,12 @@ public class CanonicalTreeParser extends AbstractTreeIterator {
 	}
 
 	@Override
-	protected byte[] idBuffer() {
+	public byte[] idBuffer() {
 		return raw;
 	}
 
 	@Override
-	protected int idOffset() {
+	public int idOffset() {
 		return rawPtr - Constants.OBJECT_ID_LENGTH;
 	}
 
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/EmptyTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/EmptyTreeIterator.java
index 73557bc..09d2bde 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/EmptyTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/EmptyTreeIterator.java
@@ -69,12 +69,12 @@ public class EmptyTreeIterator extends AbstractTreeIterator {
 	}
 
 	@Override
-	protected byte[] idBuffer() {
+	public byte[] idBuffer() {
 		return zeroid;
 	}
 
 	@Override
-	protected int idOffset() {
+	public int idOffset() {
 		return 0;
 	}
 
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 05d9282..4ac711b 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
@@ -131,7 +131,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
 	}
 
 	@Override
-	protected byte[] idBuffer() {
+	public byte[] idBuffer() {
 		if (contentIdFromPtr == ptr - 1)
 			return contentId;
 		if (entries == EOF)
@@ -229,7 +229,7 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
 	}
 
 	@Override
-	protected int idOffset() {
+	public int idOffset() {
 		return 0;
 	}
 
-- 
1.6.0.rc2.219.g1250ab

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux