Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 655:bcbcc318f250
Performance: reuse unzip output buffer
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 04 Jul 2013 18:36:38 +0200 |
parents | 1deea2f33218 |
children | ae2d439fbed3 |
comparison
equal
deleted
inserted
replaced
654:12a4f60ea972 | 655:bcbcc318f250 |
---|---|
24 import java.io.File; | 24 import java.io.File; |
25 import java.io.IOException; | 25 import java.io.IOException; |
26 import java.lang.ref.Reference; | 26 import java.lang.ref.Reference; |
27 import java.lang.ref.ReferenceQueue; | 27 import java.lang.ref.ReferenceQueue; |
28 import java.lang.ref.SoftReference; | 28 import java.lang.ref.SoftReference; |
29 import java.nio.ByteBuffer; | |
29 import java.util.ArrayList; | 30 import java.util.ArrayList; |
30 import java.util.List; | 31 import java.util.List; |
31 import java.util.zip.Inflater; | 32 import java.util.zip.Inflater; |
32 | 33 |
33 import org.tmatesoft.hg.core.HgIOException; | 34 import org.tmatesoft.hg.core.HgIOException; |
630 // | 631 // |
631 // next are transient values, for range() use only | 632 // next are transient values, for range() use only |
632 private final Inflater inflater = new Inflater(); | 633 private final Inflater inflater = new Inflater(); |
633 // can share buffer between instances of InflaterDataAccess as I never read any two of them in parallel | 634 // can share buffer between instances of InflaterDataAccess as I never read any two of them in parallel |
634 private final byte[] inflaterBuffer = new byte[10 * 1024]; // TODO [post-1.1] consider using DAP.DEFAULT_FILE_BUFFER | 635 private final byte[] inflaterBuffer = new byte[10 * 1024]; // TODO [post-1.1] consider using DAP.DEFAULT_FILE_BUFFER |
636 private final ByteBuffer inflaterOutBuffer = ByteBuffer.allocate(inflaterBuffer.length * 2); | |
635 private final byte[] nodeidBuf = new byte[20]; | 637 private final byte[] nodeidBuf = new byte[20]; |
636 // revlog record fields | 638 // revlog record fields |
637 private long offset; | 639 private long offset; |
638 @SuppressWarnings("unused") | 640 @SuppressWarnings("unused") |
639 private int flags; | 641 private int flags; |
739 userDataAccess = new DataAccess(); // empty | 741 userDataAccess = new DataAccess(); // empty |
740 } else { | 742 } else { |
741 final byte firstByte = streamDataAccess.readByte(); | 743 final byte firstByte = streamDataAccess.readByte(); |
742 if (firstByte == 0x78 /* 'x' */) { | 744 if (firstByte == 0x78 /* 'x' */) { |
743 inflater.reset(); | 745 inflater.reset(); |
744 userDataAccess = new InflaterDataAccess(streamDataAccess, streamOffset, compressedLen, isPatch(i) ? -1 : actualLen, inflater, inflaterBuffer); | 746 userDataAccess = new InflaterDataAccess(streamDataAccess, streamOffset, compressedLen, isPatch(i) ? -1 : actualLen, inflater, inflaterBuffer, inflaterOutBuffer); |
745 } else if (firstByte == 0x75 /* 'u' */) { | 747 } else if (firstByte == 0x75 /* 'u' */) { |
746 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset+1, compressedLen-1); | 748 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset+1, compressedLen-1); |
747 } else { | 749 } else { |
748 // XXX Python impl in fact throws exception when there's not 'x', 'u' or '0' but I don't see reason not to return data as is | 750 // XXX Python impl in fact throws exception when there's not 'x', 'u' or '0' but I don't see reason not to return data as is |
749 // | 751 // |