private void writeDeltaObjectDeflate(PackOutputStream out, final ObjectToPack otp) throws IOException { writeBase(out, otp.getDeltaBase()); crc32.reset(); otp.setOffset(out.length()); DeltaCache.Ref ref = otp.popCachedDelta(); if (ref != null) { byte[] zbuf = ref.get(); if (zbuf != null) { out.writeHeader(otp, otp.getCachedSize()); out.write(zbuf); typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); return; } } try (TemporaryBuffer.Heap delta = delta(otp)) { out.writeHeader(otp, delta.length()); Deflater deflater = deflater(); deflater.reset(); DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater); delta.writeTo(dst, null); dst.finish(); } typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); }
private void writeDeltaObjectDeflate(PackOutputStream out, final ObjectToPack otp) throws IOException { writeBase(out, otp.getDeltaBase()); crc32.reset(); otp.setOffset(out.length()); DeltaCache.Ref ref = otp.popCachedDelta(); if (ref != null) { byte[] zbuf = ref.get(); if (zbuf != null) { out.writeHeader(otp, otp.getCachedSize()); out.write(zbuf); typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); return; } } TemporaryBuffer.Heap delta = delta(otp); out.writeHeader(otp, delta.length()); Deflater deflater = deflater(); deflater.reset(); DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater); delta.writeTo(dst, null); dst.finish(); typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); }
private void writeDeltaObjectDeflate(PackOutputStream out, final ObjectToPack otp) throws IOException { writeBase(out, otp.getDeltaBase()); crc32.reset(); otp.setOffset(out.length()); DeltaCache.Ref ref = otp.popCachedDelta(); if (ref != null) { byte[] zbuf = ref.get(); if (zbuf != null) { out.writeHeader(otp, otp.getCachedSize()); out.write(zbuf); typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); return; } } try (TemporaryBuffer.Heap delta = delta(otp)) { out.writeHeader(otp, delta.length()); Deflater deflater = deflater(); deflater.reset(); DeflaterOutputStream dst = new DeflaterOutputStream(out, deflater); delta.writeTo(dst, null); dst.finish(); } typeStats.cntDeltas++; typeStats.deltaBytes += out.length() - otp.getOffset(); }
Ref cache(byte[] data, int actLen, int reservedSize) { // The caller may have had to allocate more space than is // required. If we are about to waste anything, shrink it. // data = resize(data, actLen); // When we reserved space for this item we did it for the // inflated size of the delta, but we were just given the // compressed version. Adjust the cache cost to match. // if (reservedSize != data.length) { used -= reservedSize; used += data.length; } return new Ref(data, queue); }
Ref cache(byte[] data, int actLen, int reservedSize) { // The caller may have had to allocate more space than is // required. If we are about to waste anything, shrink it. // data = resize(data, actLen); // When we reserved space for this item we did it for the // inflated size of the delta, but we were just given the // compressed version. Adjust the cache cost to match. // if (reservedSize != data.length) { used -= reservedSize; used += data.length; } return new Ref(data, queue); }
Ref cache(byte[] data, int actLen, int reservedSize) { // The caller may have had to allocate more space than is // required. If we are about to waste anything, shrink it. // data = resize(data, actLen); // When we reserved space for this item we did it for the // inflated size of the delta, but we were just given the // compressed version. Adjust the cache cost to match. // if (reservedSize != data.length) { used -= reservedSize; used += data.length; } return new Ref(data, queue); }