may need to flush the buffer when sliding ...
... the start of the current literal block past the beginning of the buffer
@@ -159,7 +159,7 @@ public int getLength() {
@Override
public String toString() {
- return "BackReference with " + offset + " and length " + length;
+ return "BackReference with offset " + offset + " and length " + length;
}
}
/**
@@ -198,7 +198,7 @@ public String toString() {
// 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,8 +331,12 @@ private void doCompress(byte[] data, int off, int len) throws IOException {
}
}
- 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;
