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>
This commit is contained in:
parent
677b9b17e2
commit
066df3d1a1
|
@ -71,11 +71,7 @@ public MutableObjectId() {
|
||||||
* original entry, to copy id from
|
* original entry, to copy id from
|
||||||
*/
|
*/
|
||||||
MutableObjectId(MutableObjectId src) {
|
MutableObjectId(MutableObjectId src) {
|
||||||
this.w1 = src.w1;
|
fromObjectId(src);
|
||||||
this.w2 = src.w2;
|
|
||||||
this.w3 = src.w3;
|
|
||||||
this.w4 = src.w4;
|
|
||||||
this.w5 = src.w5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make this id match {@link ObjectId#zeroId()}. */
|
/** Make this id match {@link ObjectId#zeroId()}. */
|
||||||
|
@ -87,6 +83,20 @@ public void clear() {
|
||||||
w5 = 0;
|
w5 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Convert an ObjectId from raw binary representation.
|
||||||
*
|
*
|
||||||
|
|
|
@ -281,11 +281,7 @@ public ObjectId toObjectId() {
|
||||||
public MutableEntry cloneEntry() {
|
public MutableEntry cloneEntry() {
|
||||||
final MutableEntry r = new MutableEntry();
|
final MutableEntry r = new MutableEntry();
|
||||||
ensureId();
|
ensureId();
|
||||||
r.idBuffer.w1 = idBuffer.w1;
|
r.idBuffer.fromObjectId(idBuffer);
|
||||||
r.idBuffer.w2 = idBuffer.w2;
|
|
||||||
r.idBuffer.w3 = idBuffer.w3;
|
|
||||||
r.idBuffer.w4 = idBuffer.w4;
|
|
||||||
r.idBuffer.w5 = idBuffer.w5;
|
|
||||||
r.offset = offset;
|
r.offset = offset;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue