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/11/23 17:51:41 UTC

[commons-bcel] branch master updated (7529e74d -> 3d46fb97)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git


    from 7529e74d Javadoc
     new e1304819 Make org.apache.bcel.generic.DCONST.value final
     new d1d2c2ac Make org.apache.bcel.generic.FCONST.value final
     new 3a67fafb Make org.apache.bcel.generic.ICONST.value final
     new 2d8f8787 Make org.apache.bcel.generic.LCONST.value final
     new 3d46fb97 Make org.apache.bcel.generic.SWITCH.match final

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/apache/bcel/generic/DCONST.java |  3 +-
 src/main/java/org/apache/bcel/generic/FCONST.java |  3 +-
 src/main/java/org/apache/bcel/generic/ICONST.java |  3 +-
 src/main/java/org/apache/bcel/generic/LCONST.java |  3 +-
 src/main/java/org/apache/bcel/generic/SWITCH.java | 64 +++++++++++------------
 5 files changed, 38 insertions(+), 38 deletions(-)


[commons-bcel] 02/05: Make org.apache.bcel.generic.FCONST.value final

Posted by gg...@apache.org.
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-bcel.git

commit d1d2c2acec918564eb9b6c550a979c83e55dc05f
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Wed Nov 23 10:40:45 2022 -0500

    Make org.apache.bcel.generic.FCONST.value final
---
 src/main/java/org/apache/bcel/generic/FCONST.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/bcel/generic/FCONST.java b/src/main/java/org/apache/bcel/generic/FCONST.java
index 7f14df93..17ff14dd 100644
--- a/src/main/java/org/apache/bcel/generic/FCONST.java
+++ b/src/main/java/org/apache/bcel/generic/FCONST.java
@@ -25,12 +25,13 @@ package org.apache.bcel.generic;
  */
 public class FCONST extends Instruction implements ConstantPushInstruction {
 
-    private float value;
+    private final float value;
 
     /**
      * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     FCONST() {
+        this(0);
     }
 
     public FCONST(final float f) {


[commons-bcel] 01/05: Make org.apache.bcel.generic.DCONST.value final

Posted by gg...@apache.org.
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-bcel.git

commit e13048199ab97346c4551e63ee2ae9ca18bcce7a
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Wed Nov 23 10:31:55 2022 -0500

    Make org.apache.bcel.generic.DCONST.value final
---
 src/main/java/org/apache/bcel/generic/DCONST.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/bcel/generic/DCONST.java b/src/main/java/org/apache/bcel/generic/DCONST.java
index 80da002d..7cf4192f 100644
--- a/src/main/java/org/apache/bcel/generic/DCONST.java
+++ b/src/main/java/org/apache/bcel/generic/DCONST.java
@@ -25,12 +25,13 @@ package org.apache.bcel.generic;
  */
 public class DCONST extends Instruction implements ConstantPushInstruction {
 
-    private double value;
+    private final double value;
 
     /**
      * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     DCONST() {
+        this(0);
     }
 
     public DCONST(final double f) {


[commons-bcel] 04/05: Make org.apache.bcel.generic.LCONST.value final

Posted by gg...@apache.org.
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-bcel.git

commit 2d8f87876b01aaa1fa6790727543a0ee84699419
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Wed Nov 23 10:55:57 2022 -0500

    Make org.apache.bcel.generic.LCONST.value final
---
 src/main/java/org/apache/bcel/generic/LCONST.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/bcel/generic/LCONST.java b/src/main/java/org/apache/bcel/generic/LCONST.java
index c68bf899..94a297dc 100644
--- a/src/main/java/org/apache/bcel/generic/LCONST.java
+++ b/src/main/java/org/apache/bcel/generic/LCONST.java
@@ -25,12 +25,13 @@ package org.apache.bcel.generic;
  */
 public class LCONST extends Instruction implements ConstantPushInstruction {
 
-    private long value;
+    private final long value;
 
     /**
      * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     LCONST() {
+        this(0);
     }
 
     public LCONST(final long l) {


[commons-bcel] 05/05: Make org.apache.bcel.generic.SWITCH.match final

Posted by gg...@apache.org.
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-bcel.git

commit 3d46fb9796e7adf6364f456afd5e065fd60a4f57
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Wed Nov 23 12:51:37 2022 -0500

    Make org.apache.bcel.generic.SWITCH.match final
    
    Remove unused org.apache.bcel.generic.SWITCH.targets
---
 src/main/java/org/apache/bcel/generic/SWITCH.java | 64 +++++++++++------------
 1 file changed, 30 insertions(+), 34 deletions(-)

diff --git a/src/main/java/org/apache/bcel/generic/SWITCH.java b/src/main/java/org/apache/bcel/generic/SWITCH.java
index 1c10bd64..08c9d67f 100644
--- a/src/main/java/org/apache/bcel/generic/SWITCH.java
+++ b/src/main/java/org/apache/bcel/generic/SWITCH.java
@@ -24,8 +24,7 @@ import java.util.Arrays;
  */
 public final class SWITCH implements CompoundInstruction {
 
-    private int[] match;
-    private InstructionHandle[] targets;
+    private final int[] match;
     private final Select instruction;
     private final int matchLength;
 
@@ -46,42 +45,39 @@ public final class SWITCH implements CompoundInstruction {
      * @param maxGap maximum gap that may between case branches
      */
     public SWITCH(final int[] match, final InstructionHandle[] targets, final InstructionHandle target, final int maxGap) {
-        this.match = match.clone();
-        this.targets = targets.clone();
+        int[] matchCopy = match.clone();
+        InstructionHandle[] targetsCopy = targets.clone();
         if ((matchLength = match.length) < 2) {
             instruction = new TABLESWITCH(match, targets, target);
         } else {
-            sort(0, matchLength - 1);
+            sort(0, matchLength - 1, targetsCopy);
             if (matchIsOrdered(maxGap)) {
-                fillup(maxGap, target);
-                instruction = new TABLESWITCH(this.match, this.targets, target);
+                final int maxSize = matchLength + matchLength * maxGap;
+                final int[] mVec = new int[maxSize];
+                final InstructionHandle[] tVec = new InstructionHandle[maxSize];
+                int count = 1;
+                mVec[0] = match[0];
+                tVec[0] = targets[0];
+                for (int i = 1; i < matchLength; i++) {
+                    final int prev = match[i - 1];
+                    final int gap = match[i] - prev;
+                    for (int j = 1; j < gap; j++) {
+                        mVec[count] = prev + j;
+                        tVec[count] = target;
+                        count++;
+                    }
+                    mVec[count] = match[i];
+                    tVec[count] = targets[i];
+                    count++;
+                }
+                matchCopy = Arrays.copyOf(mVec, count);
+                targetsCopy = Arrays.copyOf(tVec, count);
+                instruction = new TABLESWITCH(matchCopy, targetsCopy, target);
             } else {
-                instruction = new LOOKUPSWITCH(this.match, this.targets, target);
+                instruction = new LOOKUPSWITCH(matchCopy, targetsCopy, target);
             }
         }
-    }
-
-    private void fillup(final int maxGap, final InstructionHandle target) {
-        final int maxSize = matchLength + matchLength * maxGap;
-        final int[] mVec = new int[maxSize];
-        final InstructionHandle[] tVec = new InstructionHandle[maxSize];
-        int count = 1;
-        mVec[0] = match[0];
-        tVec[0] = targets[0];
-        for (int i = 1; i < matchLength; i++) {
-            final int prev = match[i - 1];
-            final int gap = match[i] - prev;
-            for (int j = 1; j < gap; j++) {
-                mVec[count] = prev + j;
-                tVec[count] = target;
-                count++;
-            }
-            mVec[count] = match[i];
-            tVec[count] = targets[i];
-            count++;
-        }
-        match = Arrays.copyOf(mVec, count);
-        targets = Arrays.copyOf(tVec, count);
+        this.match = matchCopy;
     }
 
     public Instruction getInstruction() {
@@ -108,7 +104,7 @@ public final class SWITCH implements CompoundInstruction {
     /**
      * Sort match and targets array with QuickSort.
      */
-    private void sort(final int l, final int r) {
+    private void sort(final int l, final int r, final InstructionHandle[] targets) {
         int i = l;
         int j = r;
         int h;
@@ -133,10 +129,10 @@ public final class SWITCH implements CompoundInstruction {
             }
         } while (i <= j);
         if (l < j) {
-            sort(l, j);
+            sort(l, j, targets);
         }
         if (i < r) {
-            sort(i, r);
+            sort(i, r, targets);
         }
     }
 }


[commons-bcel] 03/05: Make org.apache.bcel.generic.ICONST.value final

Posted by gg...@apache.org.
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-bcel.git

commit 3a67fafb3dd7cbb270db5538a108c23932d4d13e
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Wed Nov 23 10:49:16 2022 -0500

    Make org.apache.bcel.generic.ICONST.value final
---
 src/main/java/org/apache/bcel/generic/ICONST.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/bcel/generic/ICONST.java b/src/main/java/org/apache/bcel/generic/ICONST.java
index d1b9ab72..009cc319 100644
--- a/src/main/java/org/apache/bcel/generic/ICONST.java
+++ b/src/main/java/org/apache/bcel/generic/ICONST.java
@@ -25,12 +25,13 @@ package org.apache.bcel.generic;
  */
 public class ICONST extends Instruction implements ConstantPushInstruction {
 
-    private int value;
+    private final int value;
 
     /**
      * Empty constructor needed for Instruction.readInstruction. Not to be used otherwise.
      */
     ICONST() {
+        this(0);
     }
 
     public ICONST(final int i) {