[groovy] branch GROOVY_3_0_X updated (4fb0893 -> b9eac3b)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch GROOVY_3_0_X updated (4fb0893 -> b9eac3b)

Daniel.Sun
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 4fb0893  fix for "in closure" tracking
     new 07800b3  Trivial refactoring: remove unnecessarily escaped character
     new 2c94d06  Trivial refactoring: replace `isInstance` with `instanceof`  for simplicity
     new b9eac3b  Trivial refactoring: remove redundant 'Collection.addAll()' calls

The 3 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/ui/GroovyMain.java                |  2 +-
 .../codehaus/groovy/runtime/DefaultGroovyMethods.java  |  8 ++++----
 .../org/codehaus/groovy/runtime/InvokerHelper.java     |  2 +-
 .../org/codehaus/groovy/runtime/MetaClassHelper.java   |  2 +-
 .../runtime/metaclass/ConcurrentReaderHashMap.java     | 18 ++++++------------
 5 files changed, 13 insertions(+), 19 deletions(-)

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

[groovy] 01/03: Trivial refactoring: remove unnecessarily escaped character

Daniel.Sun
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 07800b39cb0b042c3b607466058429e09a65908e
Author: Daniel Sun <[hidden email]>
AuthorDate: Sun Dec 1 19:15:49 2019 +0800

    Trivial refactoring: remove unnecessarily escaped character
   
    (cherry picked from commit dd83ed81e2c5c22da7a1a0051b5051157bb84b51)
---
 src/main/java/groovy/ui/GroovyMain.java                        | 2 +-
 src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java   | 2 +-
 src/main/java/org/codehaus/groovy/runtime/MetaClassHelper.java | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/main/java/groovy/ui/GroovyMain.java b/src/main/java/groovy/ui/GroovyMain.java
index 1d9ae63..26ff489 100644
--- a/src/main/java/groovy/ui/GroovyMain.java
+++ b/src/main/java/groovy/ui/GroovyMain.java
@@ -195,7 +195,7 @@ public class GroovyMain {
         @Option(names = {"-e"}, paramLabel = "<script>", description = "Specify a command line script")
         private String script;
 
-        @Option(names = {"-i"}, arity = "0..1", paramLabel = "<extension>", description = "Modify files in place; create backup if extension is given (e.g. \'.bak\')")
+        @Option(names = {"-i"}, arity = "0..1", paramLabel = "<extension>", description = "Modify files in place; create backup if extension is given (e.g. '.bak')")
         private String extension;
 
         @Option(names = {"-n"}, description = "Process files line by line using implicit 'line' variable")
diff --git a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
index ac8779b..89013bf 100644
--- a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
+++ b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
@@ -664,7 +664,7 @@ public class InvokerHelper {
             if (verbose) {
                 String arg = escapeBackslashes((String) arguments)
                         .replaceAll("'", "\\\\'");    // single quotation mark
-                return "\'" + arg + "\'";
+                return "'" + arg + "'";
             } else {
                 return (String) arguments;
             }
diff --git a/src/main/java/org/codehaus/groovy/runtime/MetaClassHelper.java b/src/main/java/org/codehaus/groovy/runtime/MetaClassHelper.java
index f1a8646..55888bd 100644
--- a/src/main/java/org/codehaus/groovy/runtime/MetaClassHelper.java
+++ b/src/main/java/org/codehaus/groovy/runtime/MetaClassHelper.java
@@ -820,7 +820,7 @@ public class MetaClassHelper {
                 value = value.substring(0, MAX_ARG_LEN - 2) + "..";
             }
             if (argument instanceof String) {
-                value = "\'" + value + "\'";
+                value = "'" + value + "'";
             }
         } catch (Exception e) {
             value = shortName(argument);

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

[groovy] 02/03: Trivial refactoring: replace `isInstance` with `instanceof` for simplicity

Daniel.Sun
In reply to this post by Daniel.Sun
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 2c94d0641723fec4ec5cfbb2c856bda8f10abd87
Author: Daniel Sun <[hidden email]>
AuthorDate: Sun Dec 1 19:22:45 2019 +0800

    Trivial refactoring: replace `isInstance` with `instanceof`  for simplicity
   
    (cherry picked from commit 4dc2c68757bd344eaedff1d45e071fb3c9191c99)
---
 .../java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 1b2b18b..747570a 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -13460,14 +13460,14 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
         if (nlgnSort && (head instanceof Comparable)) {
             //n*LOG(n) version
             Set<T> answer;
-            if (Number.class.isInstance(head)) {
+            if (head instanceof Number) {
                 answer = new TreeSet<T>(numberComparator);
                 answer.addAll(self);
                 for (T t : self) {
-                    if (Number.class.isInstance(t)) {
+                    if (t instanceof Number) {
                         for (Object t2 : removeMe) {
-                            if (Number.class.isInstance(t2)) {
-                                if (numberComparator.compare(t, (T)t2) == 0)
+                            if (t2 instanceof Number) {
+                                if (numberComparator.compare(t, (T) t2) == 0)
                                     answer.remove(t);
                             }
                         }

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

[groovy] 03/03: Trivial refactoring: remove redundant 'Collection.addAll()' calls

Daniel.Sun
In reply to this post by Daniel.Sun
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 b9eac3b9947f0f94b943fd177b9c063ba7d6e4ce
Author: Daniel Sun <[hidden email]>
AuthorDate: Sun Dec 1 19:49:11 2019 +0800

    Trivial refactoring: remove redundant 'Collection.addAll()' calls
   
    (cherry picked from commit bb52ea08a04966ffd18999acbdfa58cb81486864)
---
 .../runtime/metaclass/ConcurrentReaderHashMap.java     | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java b/src/main/java/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java
index 1337b77..4ca393a 100644
--- a/src/main/java/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java
+++ b/src/main/java/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java
@@ -865,13 +865,11 @@ public class ConcurrentReaderHashMap
       ConcurrentReaderHashMap.this.clear();
     }
     public Object[] toArray() {
-      Collection c = new ArrayList();
-        c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray();
     }
     public Object[] toArray(Object[] a) {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray(a);
     }
   }
@@ -906,13 +904,11 @@ public class ConcurrentReaderHashMap
       ConcurrentReaderHashMap.this.clear();
     }
     public Object[] toArray() {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray();
     }
     public Object[] toArray(Object[] a) {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray(a);
     }
   }
@@ -957,13 +953,11 @@ public class ConcurrentReaderHashMap
       ConcurrentReaderHashMap.this.clear();
     }
     public Object[] toArray() {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray();
     }
     public Object[] toArray(Object[] a) {
-      Collection c = new ArrayList();
-      c.addAll(this);
+      Collection c = new ArrayList(this);
       return c.toArray(a);
     }
   }

Apache Groovy committer & PMC member

Blog: http://blog.sunlan.me
Twitter: @daniel_sun