[armedbear-cvs] r11954 - trunk/abcl/src/org/armedbear/lisp
Erik Huelsmann
ehuelsmann at common-lisp.net
Tue May 26 18:34:43 UTC 2009
Author: ehuelsmann
Date: Tue May 26 14:34:23 2009
New Revision: 11954
Log:
Remove workaround for the fact that Math.hypot() was added in Java 1.5:
We require 1.5 and hence don't need to work around it.
Modified:
trunk/abcl/src/org/armedbear/lisp/Complex.java
Modified: trunk/abcl/src/org/armedbear/lisp/Complex.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Complex.java (original)
+++ trunk/abcl/src/org/armedbear/lisp/Complex.java Tue May 26 14:34:23 2009
@@ -33,8 +33,6 @@
package org.armedbear.lisp;
-import java.lang.reflect.Method;
-
public final class Complex extends LispObject
{
public final LispObject realpart;
@@ -302,15 +300,6 @@
return !isEqualTo(obj);
}
- private static Method hypotMethod = null;
- static { try {
- hypotMethod =
- Class.forName("java.lang.Math")
- .getMethod("hypot", new Class[] { Double.TYPE, Double.TYPE });
- }
- catch (Throwable t) { Debug.trace(t); }
- }
-
@Override
public LispObject ABS() throws ConditionThrowable
{
@@ -318,31 +307,10 @@
return imagpart.ABS();
double real = DoubleFloat.coerceToFloat(realpart).value;
double imag = DoubleFloat.coerceToFloat(imagpart).value;
- try
- {
- if (hypotMethod != null)
- {
- Object[] args;
- args = new Object[2];
- args[0] = new Double(real);
- args[1] = new Double(imag);
- Double d = (Double) hypotMethod.invoke(null, args);
- if (realpart instanceof DoubleFloat)
- return new DoubleFloat(d.doubleValue());
- else
- return new SingleFloat((float)d.doubleValue());
- }
- }
- catch (Throwable t)
- {
- Debug.trace(t);
- // Fall through...
- }
- double result = Math.sqrt(real * real + imag * imag);
if (realpart instanceof DoubleFloat)
- return new DoubleFloat(result);
+ return new DoubleFloat(Math.hypot(real, imag));
else
- return new SingleFloat((float)result);
+ return new SingleFloat((float)Math.hypot(real, imag));
}
@Override
More information about the armedbear-cvs
mailing list