You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/05/16 16:03:52 UTC

[groovy] 02/02: Tweak `equals` method of `GString`

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

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 03bf143eee9224840b10aae6f153e41db9b73ff6
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat May 16 23:42:46 2020 +0800

    Tweak `equals` method of `GString`
    
    (cherry picked from commit 6b18e909518599ad585b7af269983160af4b88e6)
---
 src/main/java/groovy/lang/GString.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/groovy/lang/GString.java b/src/main/java/groovy/lang/GString.java
index 2a0c40e..ddbc007 100644
--- a/src/main/java/groovy/lang/GString.java
+++ b/src/main/java/groovy/lang/GString.java
@@ -224,10 +224,10 @@ public abstract class GString extends GroovyObjectSupport implements Comparable,
 
     @Override
     public boolean equals(Object that) {
-        if (that instanceof GString) {
-            return equals((GString) that);
-        }
-        return false;
+        if (this == that) return true;
+        if (!(that instanceof GString)) return false;
+
+        return equals((GString) that);
     }
 
     public boolean equals(GString that) {