groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Trivial refactoring: remove duplicated code of number calculation
Date Fri, 09 Mar 2018 05:01:47 GMT
Repository: groovy
Updated Branches:
  refs/heads/master f73d55170 -> c8446c770


Trivial refactoring: remove duplicated code of number calculation


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c8446c77
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c8446c77
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c8446c77

Branch: refs/heads/master
Commit: c8446c770b68e699d00557ee655adbcd5be6919e
Parents: f73d551
Author: sunlan <sunlan@apache.org>
Authored: Fri Mar 9 13:01:41 2018 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Fri Mar 9 13:01:41 2018 +0800

----------------------------------------------------------------------
 .../runtime/dgmimpl/NumberNumberMetaMethod.java | 34 +++++++++++---------
 1 file changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/c8446c77/src/main/java/org/codehaus/groovy/runtime/dgmimpl/NumberNumberMetaMethod.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/runtime/dgmimpl/NumberNumberMetaMethod.java
b/src/main/java/org/codehaus/groovy/runtime/dgmimpl/NumberNumberMetaMethod.java
index 7e588cc..6dcddfb 100644
--- a/src/main/java/org/codehaus/groovy/runtime/dgmimpl/NumberNumberMetaMethod.java
+++ b/src/main/java/org/codehaus/groovy/runtime/dgmimpl/NumberNumberMetaMethod.java
@@ -60,59 +60,61 @@ public abstract class NumberNumberMetaMethod extends CallSiteAwareMetaMethod
{
     }
 
     public CallSite createPojoCallSite(CallSite site, MetaClassImpl metaClass, MetaMethod
metaMethod, Class[] params, Object receiver, Object[] args) {
+        Object firstArg = args[0];
+
         if (receiver instanceof Integer) {
-            if (args[0] instanceof Integer)
+            if (firstArg instanceof Integer)
                 return createIntegerInteger(site, metaClass, metaMethod, params, receiver,
args);
 
-            if (args[0] instanceof Long)
+            if (firstArg instanceof Long)
                 return createIntegerLong(site, metaClass, metaMethod, params, receiver, args);
 
-            if (args[0] instanceof Float)
+            if (firstArg instanceof Float)
                 return createIntegerFloat(site, metaClass, metaMethod, params, receiver,
args);
 
-            if (args[0] instanceof Double)
+            if (firstArg instanceof Double)
                 return createIntegerDouble(site, metaClass, metaMethod, params, receiver,
args);
         }
 
         if (receiver instanceof Long) {
-            if (args[0] instanceof Integer)
+            if (firstArg instanceof Integer)
                 return createLongInteger(site, metaClass, metaMethod, params, receiver, args);
 
-            if (args[0] instanceof Long)
+            if (firstArg instanceof Long)
                 return createLongLong(site, metaClass, metaMethod, params, receiver, args);
 
-            if (args[0] instanceof Float)
+            if (firstArg instanceof Float)
                 return createLongFloat(site, metaClass, metaMethod, params, receiver, args);
 
-            if (args[0] instanceof Double)
+            if (firstArg instanceof Double)
                 return createLongDouble(site, metaClass, metaMethod, params, receiver, args);
         }
 
         if (receiver instanceof Float) {
-            if (args[0] instanceof Integer)
+            if (firstArg instanceof Integer)
                 return createFloatInteger(site, metaClass, metaMethod, params, receiver,
args);
 
-            if (args[0] instanceof Long)
+            if (firstArg instanceof Long)
                 return createFloatLong(site, metaClass, metaMethod, params, receiver, args);
 
-            if (args[0] instanceof Float)
+            if (firstArg instanceof Float)
                 return createFloatFloat(site, metaClass, metaMethod, params, receiver, args);
 
-            if (args[0] instanceof Double)
+            if (firstArg instanceof Double)
                 return createFloatDouble(site, metaClass, metaMethod, params, receiver, args);
         }
 
         if (receiver instanceof Double) {
-            if (args[0] instanceof Integer)
+            if (firstArg instanceof Integer)
                 return createDoubleInteger(site, metaClass, metaMethod, params, receiver,
args);
 
-            if (args[0] instanceof Long)
+            if (firstArg instanceof Long)
                 return createDoubleLong(site, metaClass, metaMethod, params, receiver, args);
 
-            if (args[0] instanceof Float)
+            if (firstArg instanceof Float)
                 return createDoubleFloat(site, metaClass, metaMethod, params, receiver, args);
 
-            if (args[0] instanceof Double)
+            if (firstArg instanceof Double)
                 return createDoubleDouble(site, metaClass, metaMethod, params, receiver,
args);
         }
 


Mime
View raw message