commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [06/12] commons-compress git commit: if statement can be simplified.
Date Thu, 18 Jan 2018 13:24:06 GMT
if statement can be simplified.


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/0194bb8c
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/0194bb8c
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/0194bb8c

Branch: refs/heads/master
Commit: 0194bb8ca57e5a4a3fd5fe3c39b0ccdeb4711043
Parents: eb816f6
Author: shahab <shahab.kondri@gmail.com>
Authored: Sun Jan 14 14:12:51 2018 -0500
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Thu Jan 18 14:20:49 2018 +0100

----------------------------------------------------------------------
 .../archivers/ar/ArArchiveInputStream.java      | 34 +++-----------------
 1 file changed, 5 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/0194bb8c/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
index c2de3ee..ddd122e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java
@@ -271,35 +271,11 @@ public class ArArchiveInputStream extends ArchiveInputStream {
     public static boolean matches(final byte[] signature, final int length) {
         // 3c21 7261 6863 0a3e
 
-        if (length < 8) {
-            return false;
-        }
-        if (signature[0] != 0x21) {
-            return false;
-        }
-        if (signature[1] != 0x3c) {
-            return false;
-        }
-        if (signature[2] != 0x61) {
-            return false;
-        }
-        if (signature[3] != 0x72) {
-            return false;
-        }
-        if (signature[4] != 0x63) {
-            return false;
-        }
-        if (signature[5] != 0x68) {
-            return false;
-        }
-        if (signature[6] != 0x3e) {
-            return false;
-        }
-        if (signature[7] != 0x0a) {
-            return false;
-        }
-
-        return true;
+        return length >= 8 && signature[0] == 0x21 &&
+                signature[1] == 0x3c && signature[2] == 0x61 &&
+                signature[3] == 0x72 && signature[4] == 0x63 &&
+                signature[5] == 0x68 && signature[6] == 0x3e &&
+                signature[7] == 0x0a;
     }
 
     static final String BSD_LONGNAME_PREFIX = "#1/";


Mime
View raw message