You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/03/18 20:09:48 UTC
[commons-compress] 02/02: [COMPRESS-598] Refactor commons code.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 88cb3fb8d3908a6c35ad75e1ba2a8cd1a4be98d5
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Mar 18 16:09:43 2022 -0400
[COMPRESS-598] Refactor commons code.
---
.../compress/archivers/zip/ZipArchiveInputStream.java | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
index 7f05535..7503e2a 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveInputStream.java
@@ -550,22 +550,17 @@ public class ZipArchiveInputStream extends ArchiveInputStream implements InputSt
@SuppressWarnings("resource") // checkInputStream() does not allocate.
@Override
public long getCompressedCount() {
- if (current.entry.getMethod() == ZipArchiveOutputStream.STORED) {
+ final int method = current.entry.getMethod();
+ if (method == ZipArchiveOutputStream.STORED) {
return current.bytesRead;
}
- if (current.entry.getMethod() == ZipArchiveOutputStream.DEFLATED) {
+ if (method == ZipArchiveOutputStream.DEFLATED) {
return getBytesInflated();
}
- if (current.entry.getMethod() == ZipMethod.UNSHRINKING.getCode()) {
- return ((InputStreamStatistics) current.checkInputStream()).getCompressedCount();
- }
- if (current.entry.getMethod() == ZipMethod.IMPLODING.getCode()) {
- return ((InputStreamStatistics) current.checkInputStream()).getCompressedCount();
- }
- if (current.entry.getMethod() == ZipMethod.ENHANCED_DEFLATED.getCode()) {
- return ((InputStreamStatistics) current.checkInputStream()).getCompressedCount();
- }
- if (current.entry.getMethod() == ZipMethod.BZIP2.getCode()) {
+ if (method == ZipMethod.UNSHRINKING.getCode()
+ || method == ZipMethod.IMPLODING.getCode()
+ || method == ZipMethod.ENHANCED_DEFLATED.getCode()
+ || method == ZipMethod.BZIP2.getCode()) {
return ((InputStreamStatistics) current.checkInputStream()).getCompressedCount();
}
return -1;