groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Fix "String comparison using '==', instead of 'equals()'"
Date Tue, 26 Jun 2018 00:44:13 GMT
Repository: groovy
Updated Branches:
  refs/heads/master e87d150ba -> ac0e1d232


Fix "String comparison using '==', instead of 'equals()'"


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ac0e1d23
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ac0e1d23
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ac0e1d23

Branch: refs/heads/master
Commit: ac0e1d232f0612518a87ce2aa5e443e0975cb3f4
Parents: e87d150
Author: sunlan <sunlan@apache.org>
Authored: Tue Jun 26 08:44:02 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Tue Jun 26 08:44:02 2018 +0800

----------------------------------------------------------------------
 src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java   | 3 ++-
 .../asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java  | 5 ++---
 .../org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java  | 5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/ac0e1d23/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java b/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
index 0e1a30a..e2dedf7 100644
--- a/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/ClassNodeUtils.java
@@ -36,6 +36,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 import static org.apache.groovy.ast.tools.AnnotatedNodeUtils.hasAnnotation;
 import static org.codehaus.groovy.ast.ClassHelper.boolean_TYPE;
@@ -322,7 +323,7 @@ public class ClassNodeUtils {
     public static boolean samePackageName(ClassNode first, ClassNode second) {
         String firstPackage = first.getPackageName();
         String secondPackage = second.getPackageName();
-        return (firstPackage == secondPackage)
+        return (Objects.equals(firstPackage, secondPackage))
                 || (firstPackage != null && firstPackage.equals(secondPackage));
     }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/ac0e1d23/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
index 88ef284..81773c7 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesBinaryExpressionMultiTypeDispatcher.java
@@ -62,6 +62,7 @@ import org.objectweb.asm.Opcodes;
 
 import java.lang.reflect.Modifier;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import static org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE;
@@ -256,9 +257,7 @@ public class StaticTypesBinaryExpressionMultiTypeDispatcher extends BinaryExpres
                 if (!fn.isProtected()) {
                     return false;
                 }
-                String pkg1 = receiverType.getPackageName();
-                String pkg2 = current.getPackageName();
-                if (pkg1!=pkg2 && !pkg1.equals(pkg2)) {
+                if (!Objects.equals(receiverType.getPackageName(), current.getPackageName()))
{
                     return false;
                 }
                 OperandStack operandStack = controller.getOperandStack();

http://git-wip-us.apache.org/repos/asf/groovy/blob/ac0e1d23/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java
index 19a5791..7268397 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/MetaMethodIndex.java
@@ -25,6 +25,7 @@ import org.codehaus.groovy.util.FastArray;
 import org.codehaus.groovy.util.SingleKeyHashMap;
 
 import java.util.NoSuchElementException;
+import java.util.Objects;
 
 public class MetaMethodIndex {
     public SingleKeyHashMap methodHeaders = new SingleKeyHashMap();
@@ -207,7 +208,7 @@ public class MetaMethodIndex {
         int h = hash(31 * cls.hashCode() + name.hashCode());
         Entry e = table[h & (table.length - 1)];
         for (; e != null; e = e.nextHashEntry)
-            if (e.hash == h && cls == e.cls && (e.name == name || e.name.equals(name))
)
+            if (e.hash == h && cls == e.cls && (Objects.equals(e.name, name)
|| e.name.equals(name)) )
                 return e;
 
         return null;
@@ -220,7 +221,7 @@ public class MetaMethodIndex {
         final int index = h & (t.length - 1);
         Entry e = t[index];
         for (; e != null; e = e.nextHashEntry)
-            if (e.hash == h && cls == e.cls && (e.name == name || e.name.equals(name))
)
+            if (e.hash == h && cls == e.cls && (Objects.equals(e.name, name)
|| e.name.equals(name)) )
                 return e;
 
         Entry entry = new Entry();


Mime
View raw message