Cleanup duplicated object reuse code in PackWriter

This reuse line was identical between the two branches related to
reusing a delta, or reusing a whole object.  Either way they reuse
the body of the object as-is.  So just make that a common function
after the header is written.

Change-Id: I0e6673b8e813c8c08c594ea2ba546fd366339d5d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2010-04-26 16:54:48 -07:00
parent 4ef96296f7
commit eeed0abd16
1 changed files with 5 additions and 7 deletions

View File

@ -718,12 +718,11 @@ private void writeObject(final ObjectToPack otp) throws IOException {
final PackedObjectLoader reuse = open(otp);
if (reuse != null) {
try {
if (otp.isDeltaRepresentation()) {
writeDeltaObjectReuse(otp, reuse);
} else {
if (otp.isDeltaRepresentation())
writeDeltaObjectHeader(otp, reuse);
else
writeObjectHeader(otp.getType(), reuse.getSize());
reuse.copyRawData(out, buf, windowCursor);
}
reuse.copyRawData(out, buf, windowCursor);
} finally {
reuse.endCopyRawData();
}
@ -773,7 +772,7 @@ private void writeWholeObjectDeflate(final ObjectToPack otp)
} while (!deflater.finished());
}
private void writeDeltaObjectReuse(final ObjectToPack otp,
private void writeDeltaObjectHeader(final ObjectToPack otp,
final PackedObjectLoader reuse) throws IOException {
if (deltaBaseAsOffset && otp.getDeltaBase() != null) {
writeObjectHeader(Constants.OBJ_OFS_DELTA, reuse.getRawSize());
@ -792,7 +791,6 @@ private void writeDeltaObjectReuse(final ObjectToPack otp,
otp.getDeltaBaseId().copyRawTo(buf, 0);
out.write(buf, 0, Constants.OBJECT_ID_LENGTH);
}
reuse.copyRawData(out, buf, windowCursor);
}
private void writeObjectHeader(final int objectType, long dataLength)