Permalink
Browse files

More efficient and actually works. Yay!

  • Loading branch information...
1 parent d549f0b commit 4fdfbee77e83daccf31ade63d87332c2d3353645 @samskivert committed Jun 28, 2011
Showing with 14 additions and 20 deletions.
  1. +14 −20 src/main/resources/pythagoras/util/Platform.java
@@ -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 static int hashCode (double d1) {
/**
* 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);
+ }-*/;
}

0 comments on commit 4fdfbee

Please sign in to comment.