mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8242848: Improve performance of InflaterOutputStream.write()
Reviewed-by: stuefe, vtewari, redestad, lancea
This commit is contained in:
parent
4f05f3f885
commit
2594f0b9b8
3 changed files with 215 additions and 20 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -236,16 +236,9 @@ public class InflaterOutputStream extends FilterOutputStream {
|
|||
|
||||
// Fill the decompressor buffer with output data
|
||||
if (inf.needsInput()) {
|
||||
int part;
|
||||
|
||||
if (len < 1) {
|
||||
break;
|
||||
}
|
||||
|
||||
part = (len < 512 ? len : 512);
|
||||
inf.setInput(b, off, part);
|
||||
off += part;
|
||||
len -= part;
|
||||
inf.setInput(b, off, len);
|
||||
// Only use input buffer once.
|
||||
len = 0;
|
||||
}
|
||||
|
||||
// Decompress and write blocks of output data
|
||||
|
@ -256,13 +249,14 @@ public class InflaterOutputStream extends FilterOutputStream {
|
|||
}
|
||||
} while (n > 0);
|
||||
|
||||
// Check the decompressor
|
||||
if (inf.finished()) {
|
||||
break;
|
||||
}
|
||||
// Check for missing dictionary first
|
||||
if (inf.needsDictionary()) {
|
||||
throw new ZipException("ZLIB dictionary missing");
|
||||
}
|
||||
// Check the decompressor
|
||||
if (inf.finished() || (len == 0)/* no more input */) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (DataFormatException ex) {
|
||||
// Improperly formatted compressed (ZIP) data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue