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


The following commit(s) were added to refs/heads/master by this push:
     new a4bc98bc8 Use Map.compute()
a4bc98bc8 is described below

commit a4bc98bc86c165500505c1aba9582e2297ef3fcf
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Mon Sep 2 17:10:33 2024 -0400

    Use Map.compute()
---
 .../commons/compress/archivers/zip/ZipArchiveOutputStream.java     | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
 
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
index e96664900..0ee3ab731 100644
--- 
a/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
+++ 
b/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java
@@ -711,12 +711,7 @@ public class ZipArchiveOutputStream extends 
ArchiveOutputStream<ZipArchiveEntry>
             // calculate the disk number for every central file header,
             // this will be used in writing End Of Central Directory and Zip64 
End Of Central Directory
             final int currentSplitSegment = ((ZipSplitOutputStream) 
this.out).getCurrentSplitSegmentIndex();
-            if (numberOfCDInDiskData.get(currentSplitSegment) == null) {
-                numberOfCDInDiskData.put(currentSplitSegment, 1);
-            } else {
-                final int originalNumberOfCD = 
numberOfCDInDiskData.get(currentSplitSegment);
-                numberOfCDInDiskData.put(currentSplitSegment, 
originalNumberOfCD + 1);
-            }
+            numberOfCDInDiskData.compute(currentSplitSegment, (k, v) -> v != 
null ? v + 1 : 1);
         }
 
         final byte[] extra = ze.getCentralDirectoryExtra();

Reply via email to