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;
import java.util.Arrays;
/**
* 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.
@@ -28,36 +30,28 @@ public class Platform
/**
* Clones the supplied array of bytes.
*/
public static byte[] clone (byte[] values) {
byte[] nvalues = new byte[values.length];
System.arraycopy(values, 0, nvalues, 0, values.length);
return nvalues;
}
public static native byte[] clone (byte[] values) /*-{
return values.slice(0);
}-*/;
/**
* Clones the supplied array of ints.
*/
public static int[] clone (int[] values) {
int[] nvalues = new int[values.length];
System.arraycopy(values, 0, nvalues, 0, values.length);
return nvalues;
}
public static native int[] clone (int[] values) /*-{
return values.slice(0);
}-*/;
/**
* Clones the supplied array of floats.
*/
public static float[] clone (float[] values) {
float[] nvalues = new float[values.length];
System.arraycopy(values, 0, nvalues, 0, values.length);
return nvalues;
}
public static native float[] clone (float[] values) /*-{
return values.slice(0);
}-*/;
/**
* Clones the supplied array of doubles.
*/
public static double[] clone (double[] values) {
double[] nvalues = new double[values.length];
System.arraycopy(values, 0, nvalues, 0, values.length);
return nvalues;
}
public static native double[] clone (double[] values) /*-{
return values.slice(0);
}-*/;
}