Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/InflaterDataAccess.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 | ed243b668502 |
| children |
comparison
equal
deleted
inserted
replaced
| 654:12a4f60ea972 | 655:bcbcc318f250 |
|---|---|
| 37 private final ByteBuffer outBuffer; | 37 private final ByteBuffer outBuffer; |
| 38 private int inflaterPos = 0; | 38 private int inflaterPos = 0; |
| 39 private int decompressedLength; | 39 private int decompressedLength; |
| 40 | 40 |
| 41 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength) { | 41 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength) { |
| 42 this(dataAccess, offset, compressedLength, -1, new Inflater(), new byte[512]); | 42 this(dataAccess, offset, compressedLength, -1, new Inflater(), new byte[512], null); |
| 43 } | 43 } |
| 44 | 44 |
| 45 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength, int actualLength) { | 45 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength, int actualLength) { |
| 46 this(dataAccess, offset, compressedLength, actualLength, new Inflater(), new byte[512]); | 46 this(dataAccess, offset, compressedLength, actualLength, new Inflater(), new byte[512], null); |
| 47 } | 47 } |
| 48 | 48 |
| 49 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength, int actualLength, Inflater inflater, byte[] buf) { | 49 public InflaterDataAccess(DataAccess dataAccess, long offset, int compressedLength, int actualLength, Inflater inflater, byte[] inBuf, ByteBuffer outBuf) { |
| 50 super(dataAccess, offset, compressedLength); | 50 super(dataAccess, offset, compressedLength); |
| 51 if (inflater == null || buf == null) { | 51 if (inflater == null || inBuf == null) { |
| 52 throw new IllegalArgumentException(); | 52 throw new IllegalArgumentException(); |
| 53 } | 53 } |
| 54 this.inflater = inflater; | 54 this.inflater = inflater; |
| 55 this.decompressedLength = actualLength; | 55 this.decompressedLength = actualLength; |
| 56 inBuffer = buf; | 56 inBuffer = inBuf; |
| 57 outBuffer = ByteBuffer.allocate(inBuffer.length * 2); | 57 outBuffer = outBuf == null ? ByteBuffer.allocate(inBuffer.length * 2) : outBuf; |
| 58 outBuffer.limit(0); // there's nothing to read in the buffer | 58 outBuffer.limit(0); // there's nothing to read in the buffer |
| 59 } | 59 } |
| 60 | 60 |
| 61 @Override | 61 @Override |
| 62 public InflaterDataAccess reset() throws IOException { | 62 public InflaterDataAccess reset() throws IOException { |
