Author: damjan Date: Sun Dec 1 14:02:33 2013 New Revision: 1546813 URL: http://svn.apache.org/r1546813 Log: Some cleanups to ZCompressorInputStream.
Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java?rev=1546813&r1=1546812&r2=1546813&view=diff ============================================================================== --- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java (original) +++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java Sun Dec 1 14:02:33 2013 @@ -120,25 +120,18 @@ public class ZCompressorInputStream exte } private void addEntry(int previousEntry, byte character) throws IOException { - if (tableSize >= ((1 << codeSize) - 1)) { - if (tableSize == ((1 << codeSize) - 1)) { - if (codeSize < maxCodeSize) { - reAlignReading(); - codeSize++; - prefixes[tableSize] = previousEntry; - characters[tableSize] = character; - tableSize++; - } else { - prefixes[tableSize] = previousEntry; - characters[tableSize] = character; - tableSize++; - } - } - } else { + final int maxTableSize = 1 << codeSize; + if (tableSize < maxTableSize) { prefixes[tableSize] = previousEntry; characters[tableSize] = character; tableSize++; } + if (tableSize == maxTableSize) { + if (codeSize < maxCodeSize) { + reAlignReading(); + codeSize++; + } + } } public int read() throws IOException { @@ -194,19 +187,6 @@ public class ZCompressorInputStream exte // |<--------->|<------------->|<----->|<->| // symbol symbol symbol symbol // - // Symbols are indexes into a table of table entries. Indexes - // sequentially increase up to the maximum size of the table. - // The bit count used by each index increases up to the minimum - // size needed the index the highest table entry. - // - // To construct a table entry for a symbol, - // we need the symbol's text, and the first character of the - // next symbol's text. When a symbol is the immediately previous - // table entry's symbol, that symbol's text is the previous symbol's text + 1 character. - // - // The compression process adds table entries after writing the symbol. - // Since adding entries can increase the code size, the - // final int code = readNextCode(); if (code < 0) { return -1;