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
The following commit(s) were added to refs/heads/master by this push:
new 8d2a726f Reuse Arrays.equals()
8d2a726f is described below
commit 8d2a726ff3255823e7bd96248fbf4fa85cc3560a
Author: Gary David Gregory (Code signing key) <[email protected]>
AuthorDate: Sat Oct 22 16:31:26 2022 -0400
Reuse Arrays.equals()
Spelling
---
.../bcel/verifier/statics/Pass3aVerifier.java | 26 +++++-----------------
1 file changed, 5 insertions(+), 21 deletions(-)
diff --git a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
index a066de4c..401af247 100644
--- a/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
+++ b/src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java
@@ -16,6 +16,8 @@
*/
package org.apache.bcel.verifier.statics;
+import java.util.Arrays;
+
import org.apache.bcel.Const;
import org.apache.bcel.Repository;
import org.apache.bcel.classfile.Attribute;
@@ -119,7 +121,7 @@ public final class Pass3aVerifier extends PassVerifier {
}
/**
- * A utility method to always raise an exeption.
+ * A utility method to always raise an exception.
*/
private void constraintViolated(final Instruction i, final String
message) {
throw new
StaticCodeInstructionOperandConstraintException("Instruction " + tostring(i) +
" constraint violated: " + message);
@@ -137,7 +139,7 @@ public final class Pass3aVerifier extends PassVerifier {
for (final Method element : ms) {
if
(element.getName().equals(invoke.getMethodName(constantPoolGen))
&&
Type.getReturnType(element.getSignature()).equals(invoke.getReturnType(constantPoolGen))
- &&
objArrayEquals(Type.getArgumentTypes(element.getSignature()),
invoke.getArgumentTypes(constantPoolGen))) {
+ &&
Arrays.equals(Type.getArgumentTypes(element.getSignature()),
invoke.getArgumentTypes(constantPoolGen))) {
return element;
}
}
@@ -218,24 +220,6 @@ public final class Pass3aVerifier extends PassVerifier {
}
}
- /**
- * A utility method like equals(Object) for arrays. The equality of
the elements is based on their equals(Object) method
- * instead of their object identity.
- */
- private boolean objArrayEquals(final Object[] o, final Object[] p) {
- if (o.length != p.length) {
- return false;
- }
-
- for (int i = 0; i < o.length; i++) {
- if (!o[i].equals(p[i])) {
- return false;
- }
- }
-
- return true;
- }
-
/** Checks if the constraints of operands of the said instruction(s)
are satisfied. */
@Override
public void visitALOAD(final ALOAD o) {
@@ -623,7 +607,7 @@ public final class Pass3aVerifier extends PassVerifier {
for (final Method meth2 : meths) {
if
(meth2.getName().equals(o.getMethodName(constantPoolGen))
&&
Type.getReturnType(meth2.getSignature()).equals(o.getReturnType(constantPoolGen))
- &&
objArrayEquals(Type.getArgumentTypes(meth2.getSignature()),
o.getArgumentTypes(constantPoolGen))) {
+ &&
Arrays.equals(Type.getArgumentTypes(meth2.getSignature()),
o.getArgumentTypes(constantPoolGen))) {
meth = meth2;
break;
}