From 4fdfbee77e83daccf31ade63d87332c2d3353645 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 27 Jun 2011 17:34:55 -0700 Subject: [PATCH] More efficient and actually works. Yay! --- .../resources/pythagoras/util/Platform.java | 34 ++++++++----------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/main/resources/pythagoras/util/Platform.java b/src/main/resources/pythagoras/util/Platform.java index e916471..5a078b7 100644 --- a/src/main/resources/pythagoras/util/Platform.java +++ b/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 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); + }-*/; }