// edge objects for thin packs
private final ObjectIdSubclassMap<ObjectId> edgeObjects = new ObjectIdSubclassMap<ObjectId>();
- private final Deflater deflater;
+ private int compressionLevel;
+
+ private Deflater myDeflater;
private final ObjectReader reader;
reuseSupport = null;
final CoreConfig coreConfig = configOf(repo).get(CoreConfig.KEY);
- deflater = new Deflater(coreConfig.getCompression());
+ compressionLevel = coreConfig.getCompression();
outputVersion = coreConfig.getPackIndexVersion();
}
/** Release all resources used by this writer. */
public void release() {
reader.release();
+ if (myDeflater != null) {
+ myDeflater.end();
+ myDeflater = null;
+ }
}
private void searchForReuse(ProgressMonitor compressMonitor)
private void writeWholeObjectDeflate(PackOutputStream out,
final ObjectToPack otp) throws IOException {
+ final Deflater deflater = deflater();
final ObjectLoader loader = reader.open(otp, otp.getType());
final byte[] data = loader.getCachedBytes();
out.writeHeader(otp, data.length);
} while (!deflater.finished());
}
+ private Deflater deflater() {
+ if (myDeflater == null)
+ myDeflater = new Deflater(compressionLevel);
+ return myDeflater;
+ }
+
private void writeChecksum(PackOutputStream out) throws IOException {
packcsum = out.getDigest();
out.write(packcsum);