More efficient and actually works. Yay!

This commit is contained in:
Michael Bayne
2011-06-27 17:34:55 -07:00
parent d549f0b136
commit 4fdfbee77e
@@ -4,6 +4,8 @@
package pythagoras.util; package pythagoras.util;
import java.util.Arrays;
/** /**
* A platform instance that's used when running in GWT. Note that this is copied over top of the * A platform instance that's used when running in GWT. Note that this is copied over top of the
* JDK implementation in the pythagoras.jar file, so this is never actually compiled to bytecode. * JDK implementation in the pythagoras.jar file, so this is never actually compiled to bytecode.
@@ -28,36 +30,28 @@ public class Platform
/** /**
* Clones the supplied array of bytes. * Clones the supplied array of bytes.
*/ */
public static byte[] clone (byte[] values) { public static native byte[] clone (byte[] values) /*-{
byte[] nvalues = new byte[values.length]; return values.slice(0);
System.arraycopy(values, 0, nvalues, 0, values.length); }-*/;
return nvalues;
}
/** /**
* Clones the supplied array of ints. * Clones the supplied array of ints.
*/ */
public static int[] clone (int[] values) { public static native int[] clone (int[] values) /*-{
int[] nvalues = new int[values.length]; return values.slice(0);
System.arraycopy(values, 0, nvalues, 0, values.length); }-*/;
return nvalues;
}
/** /**
* Clones the supplied array of floats. * Clones the supplied array of floats.
*/ */
public static float[] clone (float[] values) { public static native float[] clone (float[] values) /*-{
float[] nvalues = new float[values.length]; return values.slice(0);
System.arraycopy(values, 0, nvalues, 0, values.length); }-*/;
return nvalues;
}
/** /**
* Clones the supplied array of doubles. * Clones the supplied array of doubles.
*/ */
public static double[] clone (double[] values) { public static native double[] clone (double[] values) /*-{
double[] nvalues = new double[values.length]; return values.slice(0);
System.arraycopy(values, 0, nvalues, 0, values.length); }-*/;
return nvalues;
}
} }