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:50 UTC

[groovy] branch GROOVY_3_0_X updated (003ec5b -> 03bf143)

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

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


    from 003ec5b  Trivial refactoring: 'for' loop replaceable with enhanced 'for' loop
     new 1369332  Trivial refactoring: Make field final and add `@Override` to method declaration
     new 03bf143  Tweak `equals` method of `GString`

The 2 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/groovy/lang/GString.java                     | 8 ++++----
 src/main/java/org/codehaus/groovy/runtime/GStringImpl.java | 3 ++-
 2 files changed, 6 insertions(+), 5 deletions(-)


[groovy] 01/02: Trivial refactoring: Make field final and add `@Override` to method declaration

Posted by su...@apache.org.
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 136933231ab711df1158212e8442bf162b0a04d9
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat May 16 23:31:48 2020 +0800

    Trivial refactoring: Make field final and add `@Override` to method declaration
    
    (cherry picked from commit 84fc123705b9646e8e5161591dfa2e2c46a2bf27)
---
 src/main/java/org/codehaus/groovy/runtime/GStringImpl.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java b/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java
index b6f0a2c..4b660b1 100644
--- a/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java
+++ b/src/main/java/org/codehaus/groovy/runtime/GStringImpl.java
@@ -29,7 +29,7 @@ import groovy.lang.GString;
  */
 public class GStringImpl extends GString {
     private static final long serialVersionUID = 3581289038662723858L;
-    private String[] strings;
+    private final String[] strings;
 
     /**
      * Create a new GString with values and strings.
@@ -56,6 +56,7 @@ public class GStringImpl extends GString {
      * the values will result in changes of the GString. It is not recommended
      * to do so.
      */
+    @Override
     public String[] getStrings() {
         return strings;
     }


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

Posted by su...@apache.org.
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) {