Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/InflaterDataAccess.java @ 263:31f67be94e71
RevlogStream - reduce number of object instances, reuse when possible
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 18 Aug 2011 18:06:44 +0200 |
parents | b413b16d10a5 |
children | 856517285256 |
comparison
equal
deleted
inserted
replaced
262:3dcd3dd90c77 | 263:31f67be94e71 |
---|---|
39 private final byte[] singleByte = new byte[1]; | 39 private final byte[] singleByte = new byte[1]; |
40 private int decompressedPos = 0; | 40 private int decompressedPos = 0; |
41 private int decompressedLength; | 41 private int decompressedLength; |
42 | 42 |
43 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength) { | 43 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength) { |
44 this(dataAccess, offset, compressedLength, -1, new Inflater(), 512); | 44 this(dataAccess, offset, compressedLength, -1, new Inflater(), new byte[512]); |
45 } | 45 } |
46 | 46 |
47 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength, int actualLength) { | 47 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength, int actualLength) { |
48 this(dataAccess, offset, compressedLength, actualLength, new Inflater(), 512); | 48 this(dataAccess, offset, compressedLength, actualLength, new Inflater(), new byte[512]); |
49 } | 49 } |
50 | 50 |
51 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength, int actualLength, Inflater inflater, int bufSize) { | 51 public InflaterDataAccess(DataAccess dataAccess, int offset, int compressedLength, int actualLength, Inflater inflater, byte[] buf) { |
52 super(dataAccess, offset, compressedLength); | 52 super(dataAccess, offset, compressedLength); |
53 if (inflater == null || buf == null) { | |
54 throw new IllegalArgumentException(); | |
55 } | |
53 this.inflater = inflater; | 56 this.inflater = inflater; |
54 this.decompressedLength = actualLength; | 57 this.decompressedLength = actualLength; |
55 buffer = new byte[bufSize]; | 58 buffer = buf; |
56 } | 59 } |
57 | 60 |
58 @Override | 61 @Override |
59 public InflaterDataAccess reset() throws IOException { | 62 public InflaterDataAccess reset() throws IOException { |
60 super.reset(); | 63 super.reset(); |