ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ant] helfper commented on a change in pull request #145: Override ZipOutputStream.write(int)
Date Sat, 13 Mar 2021 12:39:15 GMT

helfper commented on a change in pull request #145:
URL: https://github.com/apache/ant/pull/145#discussion_r593746382



##########
File path: src/main/org/apache/tools/zip/ZipOutputStream.java
##########
@@ -901,6 +901,20 @@ public boolean canWriteEntryData(ZipEntry ae) {
         return ZipUtil.canHandleEntryData(ae);
     }
 
+    /**
+     * Writes a byte to ZIP entry.
+     *
+     * @param b the byte to write
+     * @throws IOException on error
+     * @since Ant 1.10.10
+     */
+    @Override
+    public void write(int b) throws IOException {
+        byte[] buf = new byte[1];

Review comment:
       Agreed, I thought about that but was wondering why `DeflaterOutputStream` didn't do
it. I did it now as this class is not thread-safe anyway, and this allocation on every write
may keep the GC unnecessarily busy. I checked Apache Commons Compress since you mentioned
it and it's also it's done there: https://github.com/apache/commons-compress/blob/master/src/main/java/org/apache/commons/compress/archivers/ArchiveOutputStream.java#L52




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message