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 2022/12/08 16:15:57 UTC

[commons-compress] 26/38: Convert cascading if/else to switch

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 007b09b08ed6c7ca6deee1e341d0f20ed754af9d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Dec 8 11:09:11 2022 -0500

    Convert cascading if/else to switch
---
 .../compress/harmony/unpack200/bytecode/NewAttribute.java | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
index 1b3220eb..4d942fc7 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/bytecode/NewAttribute.java
@@ -73,14 +73,21 @@ public class NewAttribute extends BCIRenumberedAttribute {
                 value = ((BCValue) obj).actualValue;
             }
             // Write
-            if (length == 1) {
+            switch (length) {
+            case 1:
                 dos.writeByte((int) value);
-            } else if (length == 2) {
+                break;
+            case 2:
                 dos.writeShort((int) value);
-            } else if (length == 4) {
+                break;
+            case 4:
                 dos.writeInt((int) value);
-            } else if (length == 8) {
+                break;
+            case 8:
                 dos.writeLong(value);
+                break;
+            default:
+                break;
             }
         }
     }