diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-22 16:42:29 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-23 16:54:15 -0700 |
commit | 066df3d1a14c3317273fe56a60948bff2edee8dc (patch) | |
tree | b11bfb0a0fb63c3357589d5a40ca7150ff8f1b42 /org.eclipse.jgit | |
parent | 677b9b17e289bcce645b03986cee1e8b30f688ec (diff) | |
download | jgit-066df3d1a14c3317273fe56a60948bff2edee8dc.tar.gz jgit-066df3d1a14c3317273fe56a60948bff2edee8dc.zip |
Add MutableObjectId.copyFrom(AnyObjectId)
This simplifies the PackIndex code, which is trying to quickly copy
an existing ObjectId into a MutableObjectId. Rather than having
the PackIndex violate the ObjectId's internals, expose a copy from
function similar to the other ones for copying from raw byte arrays
or hex formatted strings.
Change-Id: I142635cbece54af2ab83c58477961ce925dc8255
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java | 20 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java | 6 |
2 files changed, 16 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java index 2e0e0118f0..26e83d423b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/MutableObjectId.java @@ -71,11 +71,7 @@ public class MutableObjectId extends AnyObjectId { * original entry, to copy id from */ MutableObjectId(MutableObjectId src) { - this.w1 = src.w1; - this.w2 = src.w2; - this.w3 = src.w3; - this.w4 = src.w4; - this.w5 = src.w5; + fromObjectId(src); } /** Make this id match {@link ObjectId#zeroId()}. */ @@ -88,6 +84,20 @@ public class MutableObjectId extends AnyObjectId { } /** + * Copy an ObjectId into this mutable buffer. + * + * @param src + * the source id to copy from. + */ + public void fromObjectId(AnyObjectId src) { + this.w1 = src.w1; + this.w2 = src.w2; + this.w3 = src.w3; + this.w4 = src.w4; + this.w5 = src.w5; + } + + /** * Convert an ObjectId from raw binary representation. * * @param bs diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java index 25b4f569c1..13985e78e9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PackIndex.java @@ -281,11 +281,7 @@ public abstract class PackIndex implements Iterable<PackIndex.MutableEntry> { public MutableEntry cloneEntry() { final MutableEntry r = new MutableEntry(); ensureId(); - r.idBuffer.w1 = idBuffer.w1; - r.idBuffer.w2 = idBuffer.w2; - r.idBuffer.w3 = idBuffer.w3; - r.idBuffer.w4 = idBuffer.w4; - r.idBuffer.w5 = idBuffer.w5; + r.idBuffer.fromObjectId(idBuffer); r.offset = offset; return r; } |