commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [2/2] commons-compress git commit: may need to flush the buffer when sliding ...
Date Mon, 09 Jan 2017 17:59:56 GMT
may need to flush the buffer when sliding ...

... the start of the current literal block past the beginning of the buffer


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/2d70b7a2
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/2d70b7a2
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/2d70b7a2

Branch: refs/heads/master
Commit: 2d70b7a25386bff27a14e34062fa4c01d4d45681
Parents: d68eccb
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Mon Jan 9 18:59:00 2017 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Mon Jan 9 18:59:00 2017 +0100

----------------------------------------------------------------------
 .../compressors/lz77support/LZ77Compressor.java         | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/2d70b7a2/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java
b/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java
index 031a410..532090f 100644
--- a/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java
+++ b/src/main/java/org/apache/commons/compress/compressors/lz77support/LZ77Compressor.java
@@ -159,7 +159,7 @@ public class LZ77Compressor {
 
         @Override
         public String toString() {
-            return "BackReference with " + offset + " and length " + length;
+            return "BackReference with offset " + offset + " and length " + length;
         }
     }
     /**
@@ -198,7 +198,7 @@ public class LZ77Compressor {
     // the given hash.
     private final int[] head;
     // for each window-location points to the latest earlier location
-    // with the same hash. Only stored values for the latest
+    // with the same hash. Only stores values for the latest
     // "windowSize" elements, the index is "window location modulo
     // windowSize".
     private final int[] prev;
@@ -331,13 +331,17 @@ public class LZ77Compressor {
         }
     }
 
-    private void slide() {
+    private void slide() throws IOException {
         final int wSize = params.getWindowSize();
+        if (blockStart != currentPosition && blockStart < wSize) {
+            flushLiteralBlock();
+            blockStart = currentPosition;
+        }
         System.arraycopy(window, wSize, window, 0, wSize);
         currentPosition -= wSize;
         matchStart -= wSize;
         blockStart -= wSize;
-        for (int i = 0; i< HASH_SIZE; i++) {
+        for (int i = 0; i < HASH_SIZE; i++) {
             int h = head[i];
             head[i] = h >= wSize ? h - wSize : NO_MATCH;
         }


Mime
View raw message