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 2020/11/20 20:27:28 UTC

[commons-compress] branch master updated: Use a switch instead of a cascading if-else.

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 64f01c6  Use a switch instead of a cascading if-else.
64f01c6 is described below

commit 64f01c6036efef1f936ea20b738df1c1ba8d7657
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 20 15:27:22 2020 -0500

    Use a switch instead of a cascading if-else.
---
 .../compressors/deflate64/HuffmanDecoder.java      | 25 ++++++++++++++--------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java b/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
index b2956cb..b0959df 100644
--- a/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
+++ b/src/main/java/org/apache/commons/compress/compressors/deflate64/HuffmanDecoder.java
@@ -402,15 +402,22 @@ class HuffmanDecoder implements Closeable {
                 if (symbol < 16) {
                     value = symbol;
                     auxBuffer[off++] = value;
-                } else if (symbol == 16) {
-                    length = (int) (readBits(reader, 2) + 3);
-                } else if (symbol == 17) {
-                    value = 0;
-                    length = (int) (readBits(reader, 3) + 3);
-                } else if (symbol == 18) {
-                    value = 0;
-                    length = (int) (readBits(reader, 7) + 11);
-                }
+                } else
+                    switch (symbol) {
+                    case 16:
+                        length = (int) (readBits(reader, 2) + 3);
+                        break;
+                    case 17:
+                        value = 0;
+                        length = (int) (readBits(reader, 3) + 3);
+                        break;
+                    case 18:
+                        value = 0;
+                        length = (int) (readBits(reader, 7) + 11);
+                        break;
+                    default:
+                        break;
+                    }
             }
         }