[groovy] branch master updated: Trivial refactoring: replace `isInstance` with `instanceof` for simplicity

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch master updated: Trivial refactoring: replace `isInstance` with `instanceof` for simplicity

Daniel.Sun
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 4dc2c68  Trivial refactoring: replace `isInstance` with `instanceof`  for simplicity
4dc2c68 is described below

commit 4dc2c68757bd344eaedff1d45e071fb3c9191c99
Author: Daniel Sun <[hidden email]>
AuthorDate: Sun Dec 1 19:22:45 2019 +0800

    Trivial refactoring: replace `isInstance` with `instanceof`  for simplicity
---
 .../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