groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] branch master updated: Trivial refactoring: remove unnecessary boxing and unboxing for simplicity(closes #862)
Date Mon, 04 Feb 2019 18:41:03 GMT
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 12f0a09  Trivial refactoring: remove unnecessary boxing and unboxing for simplicity(closes
#862)
12f0a09 is described below

commit 12f0a099d046b9ed49464626d823237d5efca3fc
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Tue Feb 5 02:40:49 2019 +0800

    Trivial refactoring: remove unnecessary boxing and unboxing for simplicity(closes #862)
---
 .../groovy/groovy/lang/BenchmarkInterceptor.java   |  10 +-
 src/main/groovy/groovy/lang/MetaClassImpl.java     |   2 +-
 src/main/groovy/groovy/util/Expando.java           |   4 +-
 .../groovy/groovy/util/ObjectGraphBuilder.java     |   6 +-
 src/main/groovy/groovy/util/ObservableList.java    |   2 +-
 .../groovy/classgen/AsmClassGenerator.java         |   2 +-
 .../groovy/reflection/ReflectionCache.java         | 196 +++++++--------
 .../reflection/stdclasses/NumberCachedClass.java   |   2 +-
 .../groovy/runtime/DefaultGroovyMethods.java       |   6 +-
 .../org/codehaus/groovy/runtime/InvokerHelper.java |   6 +-
 .../groovy/runtime/ScriptBytecodeAdapter.java      |  14 +-
 .../callsite/BooleanReturningMethodInvoker.java    |   4 +-
 .../java/org/codehaus/groovy/syntax/Numbers.java   |  12 +-
 .../org/codehaus/groovy/util/HashCodeHelper.java   | 262 ++++++++++-----------
 14 files changed, 264 insertions(+), 264 deletions(-)

diff --git a/src/main/groovy/groovy/lang/BenchmarkInterceptor.java b/src/main/groovy/groovy/lang/BenchmarkInterceptor.java
index 77bcb64..793286d 100644
--- a/src/main/groovy/groovy/lang/BenchmarkInterceptor.java
+++ b/src/main/groovy/groovy/lang/BenchmarkInterceptor.java
@@ -74,7 +74,7 @@ public class BenchmarkInterceptor implements Interceptor {
      */
     public Object beforeInvoke(Object object, String methodName, Object[] arguments) {
         if (!calls.containsKey(methodName)) calls.put(methodName, new LinkedList());
-        ((List) calls.get(methodName)).add(Long.valueOf(System.currentTimeMillis()));
+        ((List) calls.get(methodName)).add(System.currentTimeMillis());
 
         return null;
     }
@@ -87,7 +87,7 @@ public class BenchmarkInterceptor implements Interceptor {
      * @return result
      */
     public Object afterInvoke(Object object, String methodName, Object[] arguments, Object
result) {
-        ((List) calls.get(methodName)).add(Long.valueOf(System.currentTimeMillis()));
+        ((List) calls.get(methodName)).add(System.currentTimeMillis());
         return result;
     }
 
@@ -112,14 +112,14 @@ public class BenchmarkInterceptor implements Interceptor {
             result.add(line);
             line[0] = iter.next();
             List times = (List) calls.get(line[0]);
-            line[1] = Integer.valueOf(times.size() / 2);
+            line[1] = times.size() / 2;
             int accTime = 0;
             for (Iterator it = times.iterator(); it.hasNext();) {
                 Long start = (Long) it.next();
                 Long end = (Long) it.next();
-                accTime += end.longValue() - start.longValue();
+                accTime += end - start;
             }
-            line[2] = Long.valueOf(accTime);
+            line[2] = (long) accTime;
         }
         return result;
     }
diff --git a/src/main/groovy/groovy/lang/MetaClassImpl.java b/src/main/groovy/groovy/lang/MetaClassImpl.java
index e4cb082..cf9c3ef 100644
--- a/src/main/groovy/groovy/lang/MetaClassImpl.java
+++ b/src/main/groovy/groovy/lang/MetaClassImpl.java
@@ -1096,7 +1096,7 @@ public class MetaClassImpl implements MetaClass, MutableMetaClass {
             // try to invoke method with adjusted arguments(first argument is the actual
owner) again.
             // otherwise throw the MissingMethodExceptionNoStack.
             if (!(owner instanceof Class
-                    && ((Boolean) mc.getProperty(MethodClosure.ANY_INSTANCE_METHOD_EXISTS)).booleanValue()))
{
+                    && (Boolean) mc.getProperty(MethodClosure.ANY_INSTANCE_METHOD_EXISTS)))
{
 
                 throw e;
             }
diff --git a/src/main/groovy/groovy/util/Expando.java b/src/main/groovy/groovy/util/Expando.java
index 21a2931..a156fdb 100644
--- a/src/main/groovy/groovy/util/Expando.java
+++ b/src/main/groovy/groovy/util/Expando.java
@@ -134,7 +134,7 @@ public class Expando extends GroovyObjectSupport {
             Closure closure = (Closure) method;
             closure.setDelegate(this);
             Boolean ret = (Boolean) closure.call(obj);
-            return ret.booleanValue();
+            return ret;
         } else {
             return super.equals(obj);
         }
@@ -153,7 +153,7 @@ public class Expando extends GroovyObjectSupport {
             Closure closure = (Closure) method;
             closure.setDelegate(this);
             Integer ret = (Integer) closure.call();
-            return ret.intValue();
+            return ret;
         } else {
             return super.hashCode();
         }
diff --git a/src/main/groovy/groovy/util/ObjectGraphBuilder.java b/src/main/groovy/groovy/util/ObjectGraphBuilder.java
index b26a966..b6b6b48 100644
--- a/src/main/groovy/groovy/util/ObjectGraphBuilder.java
+++ b/src/main/groovy/groovy/util/ObjectGraphBuilder.java
@@ -801,7 +801,7 @@ public class ObjectGraphBuilder extends FactoryBuilderSupport {
             context.put(ObjectGraphBuilder.NODE_NAME, name);
             context.put(ObjectGraphBuilder.LAZY_REF, lazy);
 
-            if (lazy.booleanValue()) {
+            if (lazy) {
                 Map parentContext = ogbuilder.getParentContext();
 
                 Object parent = null;
@@ -824,12 +824,12 @@ public class ObjectGraphBuilder extends FactoryBuilderSupport {
 
         public void setChild(FactoryBuilderSupport builder, Object parent, Object child)
{
             Boolean lazy = (Boolean) builder.getContext().get(ObjectGraphBuilder.LAZY_REF);
-            if (!lazy.booleanValue()) super.setChild(builder, parent, child);
+            if (!lazy) super.setChild(builder, parent, child);
         }
 
         public void setParent(FactoryBuilderSupport builder, Object parent, Object child)
{
             Boolean lazy = (Boolean) builder.getContext().get(ObjectGraphBuilder.LAZY_REF);
-            if (!lazy.booleanValue()) super.setParent(builder, parent, child);
+            if (!lazy) super.setParent(builder, parent, child);
         }
     }
 
diff --git a/src/main/groovy/groovy/util/ObservableList.java b/src/main/groovy/groovy/util/ObservableList.java
index 7684596..84a9c89 100644
--- a/src/main/groovy/groovy/util/ObservableList.java
+++ b/src/main/groovy/groovy/util/ObservableList.java
@@ -321,7 +321,7 @@ public class ObservableList implements List {
         Object oldValue = delegate.set(index, element);
         if (test != null) {
             Object result = test.call(element);
-            if (result instanceof Boolean && ((Boolean) result).booleanValue()) {
+            if (result instanceof Boolean && (Boolean) result) {
                 fireElementUpdatedEvent(index, oldValue, element);
             }
         } else {
diff --git a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
index 9f33680..203c518 100644
--- a/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/java/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -1630,7 +1630,7 @@ public class AsmClassGenerator extends ClassGenerator {
             if (!(expr instanceof SpreadExpression)) {
                 normalArguments.add(expr);
             } else {
-                spreadIndexes.add(new ConstantExpression(Integer.valueOf(i - spreadExpressions.size()),true));
+                spreadIndexes.add(new ConstantExpression(i - spreadExpressions.size(),true));
                 spreadExpressions.add(((SpreadExpression) expr).getExpression());
             }
         }
diff --git a/src/main/java/org/codehaus/groovy/reflection/ReflectionCache.java b/src/main/java/org/codehaus/groovy/reflection/ReflectionCache.java
index 1ae2f27..7f6c525 100644
--- a/src/main/java/org/codehaus/groovy/reflection/ReflectionCache.java
+++ b/src/main/java/org/codehaus/groovy/reflection/ReflectionCache.java
@@ -1,98 +1,98 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.codehaus.groovy.reflection;
-
-import org.codehaus.groovy.classgen.asm.util.TypeUtil;
-import org.codehaus.groovy.util.TripleKeyHashMap;
-
-public class ReflectionCache {
-    public static Class autoboxType(Class type) {
-        return TypeUtil.autoboxType(type);
-    }
-
-    static TripleKeyHashMap mopNames = new TripleKeyHashMap();
-
-    public static String getMOPMethodName(CachedClass declaringClass, String name, boolean
useThis) {
-        TripleKeyHashMap.Entry mopNameEntry = mopNames.getOrPut(declaringClass, name, Boolean.valueOf(useThis));
-        if (mopNameEntry.value == null) {
-            mopNameEntry.value = (useThis ? "this$" : "super$") + declaringClass.getSuperClassDistance()
+ "$" + name;
-        }
-        return (String) mopNameEntry.value;
-    }
-    
-    static final CachedClass STRING_CLASS = getCachedClass(String.class);
-
-    public static boolean isArray(Class klazz) {
-      return klazz.isArray();
-    }
-
-    static void setAssignableFrom(Class klazz, Class aClass) {
-        // FIXME no implementation?
-//        SoftDoubleKeyMap.Entry val = (SoftDoubleKeyMap.Entry) assignableMap.getOrPut(klazz,
aClass, null);
-//        if (val.getValue() == null) {
-//            val.setValue(Boolean.TRUE);
-//        }
-    }
-
-    public static boolean isAssignableFrom(Class klazz, Class aClass) {
-        if (klazz == aClass)
-          return true;
-
-//        SoftDoubleKeyMap.Entry val = (SoftDoubleKeyMap.Entry) assignableMap.getOrPut(klazz,
aClass, null);
-//        if (val.getValue() == null) {
-//            val.setValue(Boolean.valueOf(klazz.isAssignableFrom(aClass)));
-//        }
-//        return ((Boolean)val.getValue()).booleanValue();
-        return klazz.isAssignableFrom(aClass);
-    }
-
-    static boolean arrayContentsEq(Object[] a1, Object[] a2) {
-        if (a1 == null) {
-            return a2 == null || a2.length == 0;
-        }
-
-        if (a2 == null) {
-            return a1.length == 0;
-        }
-
-        if (a1.length != a2.length) {
-            return false;
-        }
-
-        for (int i = 0; i < a1.length; i++) {
-            if (a1[i] != a2[i]) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    public static final CachedClass OBJECT_CLASS = getCachedClass(Object.class);
-
-    public static final CachedClass OBJECT_ARRAY_CLASS = getCachedClass(Object[].class);
-
-    public static CachedClass getCachedClass(Class klazz) {
-        if (klazz == null)
-          return null;
-        
-        return ClassInfo.getClassInfo(klazz).getCachedClass();
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.reflection;
+
+import org.codehaus.groovy.classgen.asm.util.TypeUtil;
+import org.codehaus.groovy.util.TripleKeyHashMap;
+
+public class ReflectionCache {
+    public static Class autoboxType(Class type) {
+        return TypeUtil.autoboxType(type);
+    }
+
+    static TripleKeyHashMap mopNames = new TripleKeyHashMap();
+
+    public static String getMOPMethodName(CachedClass declaringClass, String name, boolean
useThis) {
+        TripleKeyHashMap.Entry mopNameEntry = mopNames.getOrPut(declaringClass, name, useThis);
+        if (mopNameEntry.value == null) {
+            mopNameEntry.value = (useThis ? "this$" : "super$") + declaringClass.getSuperClassDistance()
+ "$" + name;
+        }
+        return (String) mopNameEntry.value;
+    }
+    
+    static final CachedClass STRING_CLASS = getCachedClass(String.class);
+
+    public static boolean isArray(Class klazz) {
+      return klazz.isArray();
+    }
+
+    static void setAssignableFrom(Class klazz, Class aClass) {
+        // FIXME no implementation?
+//        SoftDoubleKeyMap.Entry val = (SoftDoubleKeyMap.Entry) assignableMap.getOrPut(klazz,
aClass, null);
+//        if (val.getValue() == null) {
+//            val.setValue(Boolean.TRUE);
+//        }
+    }
+
+    public static boolean isAssignableFrom(Class klazz, Class aClass) {
+        if (klazz == aClass)
+          return true;
+
+//        SoftDoubleKeyMap.Entry val = (SoftDoubleKeyMap.Entry) assignableMap.getOrPut(klazz,
aClass, null);
+//        if (val.getValue() == null) {
+//            val.setValue(Boolean.valueOf(klazz.isAssignableFrom(aClass)));
+//        }
+//        return ((Boolean)val.getValue()).booleanValue();
+        return klazz.isAssignableFrom(aClass);
+    }
+
+    static boolean arrayContentsEq(Object[] a1, Object[] a2) {
+        if (a1 == null) {
+            return a2 == null || a2.length == 0;
+        }
+
+        if (a2 == null) {
+            return a1.length == 0;
+        }
+
+        if (a1.length != a2.length) {
+            return false;
+        }
+
+        for (int i = 0; i < a1.length; i++) {
+            if (a1[i] != a2[i]) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public static final CachedClass OBJECT_CLASS = getCachedClass(Object.class);
+
+    public static final CachedClass OBJECT_ARRAY_CLASS = getCachedClass(Object[].class);
+
+    public static CachedClass getCachedClass(Class klazz) {
+        if (klazz == null)
+          return null;
+        
+        return ClassInfo.getClassInfo(klazz).getCachedClass();
+    }
+
+}
diff --git a/src/main/java/org/codehaus/groovy/reflection/stdclasses/NumberCachedClass.java
b/src/main/java/org/codehaus/groovy/reflection/stdclasses/NumberCachedClass.java
index 70a9a35..df3e6d0 100644
--- a/src/main/java/org/codehaus/groovy/reflection/stdclasses/NumberCachedClass.java
+++ b/src/main/java/org/codehaus/groovy/reflection/stdclasses/NumberCachedClass.java
@@ -52,7 +52,7 @@ public class NumberCachedClass extends CachedClass {
     private Object coerceNumber(Object argument) {
         Class param = getTheClass();
         if (param == Byte.class /*|| param == Byte.TYPE*/) {
-            argument = Byte.valueOf(((Number) argument).byteValue());
+            argument = ((Number) argument).byteValue();
         } else if (param == BigInteger.class) {
             argument = new BigInteger(String.valueOf((Number) argument));
         }
diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index db43fd2..6368600 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -16106,7 +16106,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
{
      * @since 1.0
      */
     public static long abs(Long number) {
-        return Math.abs(number.longValue());
+        return Math.abs(number);
     }
 
     /**
@@ -16117,7 +16117,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
{
      * @since 1.0
      */
     public static float abs(Float number) {
-        return Math.abs(number.floatValue());
+        return Math.abs(number);
     }
 
     /**
@@ -16139,7 +16139,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
{
      * @since 1.0
      */
     public static int round(Float number) {
-        return Math.round(number.floatValue());
+        return Math.round(number);
     }
 
     /**
diff --git a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
index 77674dd..1e6781f 100644
--- a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
+++ b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
@@ -263,7 +263,7 @@ public class InvokerHelper {
     public static Object unaryMinus(Object value) {
         if (value instanceof Integer) {
             Integer number = (Integer) value;
-            return Integer.valueOf(-number.intValue());
+            return -number;
         }
         if (value instanceof Long) {
             Long number = (Long) value;
@@ -285,11 +285,11 @@ public class InvokerHelper {
         }
         if (value instanceof Short) {
             Short number = (Short) value;
-            return Short.valueOf((short) -number.shortValue());
+            return (short) -number;
         }
         if (value instanceof Byte) {
             Byte number = (Byte) value;
-            return Byte.valueOf((byte) -number.byteValue());
+            return (byte) -number;
         }
         if (value instanceof ArrayList) {
             // value is a list.
diff --git a/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java b/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java
index 39473d2..df1a4c4 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ScriptBytecodeAdapter.java
@@ -51,9 +51,9 @@ import java.util.regex.Pattern;
  */
 public class ScriptBytecodeAdapter {
     public static final Object[] EMPTY_ARGS = {};
-    private static final Integer ZERO = Integer.valueOf(0);
-    private static final Integer MINUS_ONE = Integer.valueOf(-1);
-    private static final Integer ONE = Integer.valueOf(1);
+    private static final Integer ZERO = 0;
+    private static final Integer MINUS_ONE = -1;
+    private static final Integer ONE = 1;
 
     //  --------------------------------------------------------
     //                   exception handling
@@ -733,7 +733,7 @@ public class ScriptBytecodeAdapter {
         if (leftClass ==Long.class && rightClass==Long.class) {
             return (Long) left < (Long) right;
         }
-        return compareTo(left, right).intValue() < 0;
+        return compareTo(left, right) < 0;
     }
 
     public static boolean compareLessThanEqual(Object left, Object right) {
@@ -748,7 +748,7 @@ public class ScriptBytecodeAdapter {
         if (leftClass ==Long.class && rightClass==Long.class) {
             return (Long) left <= (Long) right;
         }
-        return compareTo(left, right).intValue() <= 0;
+        return compareTo(left, right) <= 0;
     }
 
     public static boolean compareGreaterThan(Object left, Object right) {
@@ -763,7 +763,7 @@ public class ScriptBytecodeAdapter {
         if (leftClass ==Long.class && rightClass==Long.class) {
             return (Long) left > (Long) right;
         }
-        return compareTo(left, right).intValue() > 0;
+        return compareTo(left, right) > 0;
     }
 
     public static boolean compareGreaterThanEqual(Object left, Object right) {
@@ -778,7 +778,7 @@ public class ScriptBytecodeAdapter {
         if (leftClass ==Long.class && rightClass==Long.class) {
             return (Long) left >= (Long) right;
         }
-        return compareTo(left, right).intValue() >= 0;
+        return compareTo(left, right) >= 0;
     }
 
     //regexpr
diff --git a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanReturningMethodInvoker.java
b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanReturningMethodInvoker.java
index 7865f05..9a36700 100644
--- a/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanReturningMethodInvoker.java
+++ b/src/main/java/org/codehaus/groovy/runtime/callsite/BooleanReturningMethodInvoker.java
@@ -59,7 +59,7 @@ public class BooleanReturningMethodInvoker {
         // handle conversion to boolean
         if (arg == null) return false;
         if (arg instanceof Boolean) {
-            return ((Boolean) arg).booleanValue();
+            return (Boolean) arg;
         }
         // it was not null and not boolean, so call asBoolean
         try {
@@ -68,7 +68,7 @@ public class BooleanReturningMethodInvoker {
             // UncheckedThrow allows throwing checked exceptions without declaring a throws
             UncheckedThrow.rethrow(t);
         }
-        return ((Boolean) arg).booleanValue();
+        return (Boolean) arg;
     }
 
 }
diff --git a/src/main/java/org/codehaus/groovy/syntax/Numbers.java b/src/main/java/org/codehaus/groovy/syntax/Numbers.java
index d08a2f3..be43e69 100644
--- a/src/main/java/org/codehaus/groovy/syntax/Numbers.java
+++ b/src/main/java/org/codehaus/groovy/syntax/Numbers.java
@@ -202,13 +202,13 @@ public class Numbers {
                 if (radix == 10 && (value.compareTo(MAX_INTEGER) > 0 || value.compareTo(MIN_INTEGER)
< 0)) {
                     throw new ASTRuntimeException(reportNode, "Number of value " + value
+ " does not fit in the range of int, but int was enforced.");
                 } else {
-                    return Integer.valueOf(value.intValue());
+                    return value.intValue();
                 }
             case 'l':
                 if (radix == 10 && (value.compareTo(MAX_LONG) > 0 || value.compareTo(MIN_LONG)
< 0)) {
                     throw new ASTRuntimeException(reportNode, "Number of value " + value
+ " does not fit in the range of long, but long was enforced.");
                 } else {
-                    return Long.valueOf(value.longValue());
+                    return value.longValue();
                 }
             case 'g':
                 return value;
@@ -216,9 +216,9 @@ public class Numbers {
                 // If not specified, we will return the narrowest possible
                 // of Integer, Long, and BigInteger.
                 if (value.compareTo(MAX_INTEGER) <= 0 && value.compareTo(MIN_INTEGER)
>= 0) {
-                    return Integer.valueOf(value.intValue());
+                    return value.intValue();
                 } else if (value.compareTo(MAX_LONG) <= 0 && value.compareTo(MIN_LONG)
>= 0) {
-                    return Long.valueOf(value.longValue());
+                    return value.longValue();
                 }
                 return value;
         }
@@ -257,13 +257,13 @@ public class Numbers {
         switch (type) {
             case 'f':
                 if (value.compareTo(MAX_FLOAT) <= 0 && value.compareTo(MIN_FLOAT)
>= 0) {
-                    return new Float(text);
+                    return Float.parseFloat(text);
                 }
                 throw new NumberFormatException("out of range");
 
             case 'd':
                 if (value.compareTo(MAX_DOUBLE) <= 0 && value.compareTo(MIN_DOUBLE)
>= 0) {
-                    return new Double(text);
+                    return Double.parseDouble(text);
                 }
                 throw new NumberFormatException("out of range");
 
diff --git a/src/main/java/org/codehaus/groovy/util/HashCodeHelper.java b/src/main/java/org/codehaus/groovy/util/HashCodeHelper.java
index 9e7afc9..8554f27 100644
--- a/src/main/java/org/codehaus/groovy/util/HashCodeHelper.java
+++ b/src/main/java/org/codehaus/groovy/util/HashCodeHelper.java
@@ -1,131 +1,131 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package org.codehaus.groovy.util;
-
-import java.util.Arrays;
-
-/**
- * A utility class to help calculate hashcode values
- * using an algorithm similar to that outlined in
- * "Effective Java, Joshua Bloch, 2nd Edition".
- */
-public class HashCodeHelper {
-    private static final int SEED = 127;
-    private static final int MULT = 59;
-
-    public static int initHash() {
-        return SEED;
-    }
-
-    public static int updateHash(int current, boolean var) {
-        return shift(current) + (var ? 79 : 97);
-    }
-
-    public static int updateHash(int current, char var) {
-        return shift(current) + (int) var;
-    }
-
-    public static int updateHash(int current, Character var) {
-        return updateHash(current, var == null ? 0 : var.charValue());
-    }
-
-    public static int updateHash(int current, int var) {
-        return shift(current) + var;
-    }
-
-    public static int updateHash(int current, Integer var) {
-        return updateHash(current, var == null ? 0 : var.intValue());
-    }
-
-    public static int updateHash(int current, long var) {
-        return shift(current) + (int) (var ^ (var >>> 32));
-    }
-
-    public static int updateHash(int current, Long var) {
-        return updateHash(current, var == null ? 0L : var.longValue());
-    }
-
-    public static int updateHash(int current, float var) {
-        return updateHash(current, Float.floatToIntBits(var));
-    }
-
-    public static int updateHash(int current, Float var) {
-        return updateHash(current, var == null ? 0f : var.floatValue());
-    }
-
-    public static int updateHash(int current, double var) {
-        return updateHash(current, Double.doubleToLongBits(var));
-    }
-
-    public static int updateHash(int current, Double var) {
-        return updateHash(current, var == null ? 0d : var.doubleValue());
-    }
-
-    public static int updateHash(int current, Object var) {
-        if (var == null) return updateHash(current, 0);
-        if (var.getClass().isArray())
-            return shift(current) + Arrays.hashCode((Object[]) var);
-        return updateHash(current, var.hashCode());
-    }
-
-    public static int updateHash(int current, boolean[] var) {
-        if (var == null) return updateHash(current, 0);
-        return shift(current) + Arrays.hashCode(var);
-    }
-
-    public static int updateHash(int current, char[] var) {
-        if (var == null) return updateHash(current, 0);
-        return shift(current) + Arrays.hashCode(var);
-    }
-
-    public static int updateHash(int current, byte[] var) {
-        if (var == null) return updateHash(current, 0);
-        return shift(current) + Arrays.hashCode(var);
-    }
-
-    public static int updateHash(int current, short[] var) {
-        if (var == null) return updateHash(current, 0);
-        return shift(current) + Arrays.hashCode(var);
-    }
-
-    public static int updateHash(int current, int[] var) {
-        if (var == null) return updateHash(current, 0);
-        return shift(current) + Arrays.hashCode(var);
-    }
-
-    public static int updateHash(int current, long[] var) {
-        if (var == null) return updateHash(current, 0);
-        return shift(current) + Arrays.hashCode(var);
-    }
-
-    public static int updateHash(int current, float[] var) {
-        if (var == null) return updateHash(current, 0);
-        return shift(current) + Arrays.hashCode(var);
-    }
-
-    public static int updateHash(int current, double[] var) {
-        if (var == null) return updateHash(current, 0);
-        return shift(current) + Arrays.hashCode(var);
-    }
-
-    private static int shift(int current) {
-        return MULT * current;
-    }
-
-}
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.util;
+
+import java.util.Arrays;
+
+/**
+ * A utility class to help calculate hashcode values
+ * using an algorithm similar to that outlined in
+ * "Effective Java, Joshua Bloch, 2nd Edition".
+ */
+public class HashCodeHelper {
+    private static final int SEED = 127;
+    private static final int MULT = 59;
+
+    public static int initHash() {
+        return SEED;
+    }
+
+    public static int updateHash(int current, boolean var) {
+        return shift(current) + (var ? 79 : 97);
+    }
+
+    public static int updateHash(int current, char var) {
+        return shift(current) + (int) var;
+    }
+
+    public static int updateHash(int current, Character var) {
+        return updateHash(current, var == null ? 0 : var);
+    }
+
+    public static int updateHash(int current, int var) {
+        return shift(current) + var;
+    }
+
+    public static int updateHash(int current, Integer var) {
+        return updateHash(current, var == null ? 0 : var);
+    }
+
+    public static int updateHash(int current, long var) {
+        return shift(current) + (int) (var ^ (var >>> 32));
+    }
+
+    public static int updateHash(int current, Long var) {
+        return updateHash(current, var == null ? 0L : var);
+    }
+
+    public static int updateHash(int current, float var) {
+        return updateHash(current, Float.floatToIntBits(var));
+    }
+
+    public static int updateHash(int current, Float var) {
+        return updateHash(current, var == null ? 0f : var);
+    }
+
+    public static int updateHash(int current, double var) {
+        return updateHash(current, Double.doubleToLongBits(var));
+    }
+
+    public static int updateHash(int current, Double var) {
+        return updateHash(current, var == null ? 0d : var);
+    }
+
+    public static int updateHash(int current, Object var) {
+        if (var == null) return updateHash(current, 0);
+        if (var.getClass().isArray())
+            return shift(current) + Arrays.hashCode((Object[]) var);
+        return updateHash(current, var.hashCode());
+    }
+
+    public static int updateHash(int current, boolean[] var) {
+        if (var == null) return updateHash(current, 0);
+        return shift(current) + Arrays.hashCode(var);
+    }
+
+    public static int updateHash(int current, char[] var) {
+        if (var == null) return updateHash(current, 0);
+        return shift(current) + Arrays.hashCode(var);
+    }
+
+    public static int updateHash(int current, byte[] var) {
+        if (var == null) return updateHash(current, 0);
+        return shift(current) + Arrays.hashCode(var);
+    }
+
+    public static int updateHash(int current, short[] var) {
+        if (var == null) return updateHash(current, 0);
+        return shift(current) + Arrays.hashCode(var);
+    }
+
+    public static int updateHash(int current, int[] var) {
+        if (var == null) return updateHash(current, 0);
+        return shift(current) + Arrays.hashCode(var);
+    }
+
+    public static int updateHash(int current, long[] var) {
+        if (var == null) return updateHash(current, 0);
+        return shift(current) + Arrays.hashCode(var);
+    }
+
+    public static int updateHash(int current, float[] var) {
+        if (var == null) return updateHash(current, 0);
+        return shift(current) + Arrays.hashCode(var);
+    }
+
+    public static int updateHash(int current, double[] var) {
+        if (var == null) return updateHash(current, 0);
+        return shift(current) + Arrays.hashCode(var);
+    }
+
+    private static int shift(int current) {
+        return MULT * current;
+    }
+
+}


Mime
View raw message