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 15:43:05 UTC

[groovy] branch master updated: Tweak `equals` method of `GString`

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6b18e90  Tweak `equals` method of `GString`
6b18e90 is described below

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

    Tweak `equals` method of `GString`
---
 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) {