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 2025/05/31 12:58:44 UTC
(commons-compress) 02/07: Simplify internals
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 c133778533d7d1c533f1ce36824ab5481aa64ac2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat May 31 08:13:16 2025 -0400
Simplify internals
Comments
---
.../org/apache/commons/compress/archivers/tar/TarUtils.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
index 76c4577ad..0c325b3c6 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java
@@ -74,13 +74,7 @@ public String decode(final byte[] buffer) {
@Override
public ByteBuffer encode(final String name) {
- final int length = name.length();
- final byte[] buf = new byte[length];
- // copy until end of input or output is reached.
- for (int i = 0; i < length; ++i) {
- buf[i] = (byte) name.charAt(i);
- }
- return ByteBuffer.wrap(buf);
+ return ByteBuffer.wrap(name.getBytes(StandardCharsets.US_ASCII));
}
};
@@ -98,7 +92,9 @@ public static long computeCheckSum(final byte[] buf) {
return sum;
}
- // Helper method to generate the exception message
+ /*
+ * Generates an exception message.
+ */
private static String exceptionMessage(final byte[] buffer, final int offset, final int length, final int current, final byte currentByte) {
// default charset is good enough for an exception message,
//