only flush if there is something to flush

This commit is contained in:
kimchy 2010-10-29 17:50:51 +02:00
parent 11c55185e8
commit 8f7a8dabc1
3 changed files with 10 additions and 4 deletions

View File

@ -34,7 +34,9 @@
<RunnerSettings RunnerId="Profile ">
<option name="myExternalizedOptions" value="&#10;additional-options2=onexit\=snapshot&#10;" />
</RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>

View File

@ -82,7 +82,9 @@ public class LZFOutputStream extends OutputStream {
* Compress and write the current block to the OutputStream
*/
private void writeCompressedBlock() throws IOException {
encoder.encodeChunk(outputStream, outputBuffer, 0, position);
position = 0;
if (position > 0) {
encoder.encodeChunk(outputStream, outputBuffer, 0, position);
position = 0;
}
}
}

View File

@ -103,7 +103,9 @@ public class LZFStreamOutput extends StreamOutput {
* Compress and write the current block to the OutputStream
*/
private void writeCompressedBlock() throws IOException {
encoder.encodeChunk(out, outputBuffer, 0, position);
position = 0;
if (position > 0) {
encoder.encodeChunk(out, outputBuffer, 0, position);
position = 0;
}
}
}