diff --git a/deft4j-base/src/main/java/com/github/NeRdTheNed/deft4j/deflate/DeflateStream.java b/deft4j-base/src/main/java/com/github/NeRdTheNed/deft4j/deflate/DeflateStream.java index 38fa0cc..1b6224a 100644 --- a/deft4j-base/src/main/java/com/github/NeRdTheNed/deft4j/deflate/DeflateStream.java +++ b/deft4j-base/src/main/java/com/github/NeRdTheNed/deft4j/deflate/DeflateStream.java @@ -558,7 +558,13 @@ public long optimise() { // TODO Try other types of blocks // TODO Try merging more block types // TODO Try merging blocks at different passes - saved += mergeBlocks(); + final long mergeSaved = mergeBlocks(); + saved += mergeSaved; + + if (mergeSaved > 0) { + return saved + optimise(); + } + return saved; }