From 6cf332f996d313772a29f0e29caf997c3908ed99 Mon Sep 17 00:00:00 2001 From: Ned Loynd Date: Thu, 9 Nov 2023 13:03:29 +1100 Subject: [PATCH] Run optimisations on merged blocks --- .../github/NeRdTheNed/deft4j/deflate/DeflateStream.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; }