From 8ff0aa8ddfd11e78443f75de392b9a55c47a5f1d Mon Sep 17 00:00:00 2001 From: dariuszzbyrad Date: Thu, 27 Aug 2020 02:12:40 +0200 Subject: [PATCH] Using embedded copying of an array instead of manual (#9073) Signed-off-by: Dariusz Zbyrad --- .../main/java/org/datavec/python/PythonExecutioner.java | 5 +---- .../src/main/java/org/datavec/python/PythonProcess.java | 8 ++------ 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/datavec/datavec-python/src/main/java/org/datavec/python/PythonExecutioner.java b/datavec/datavec-python/src/main/java/org/datavec/python/PythonExecutioner.java index dd48cb104..c6c28262b 100644 --- a/datavec/datavec-python/src/main/java/org/datavec/python/PythonExecutioner.java +++ b/datavec/datavec-python/src/main/java/org/datavec/python/PythonExecutioner.java @@ -345,10 +345,7 @@ public class PythonExecutioner { //// TODO: fix in javacpp File sitePackagesWindows = new File(python.cachePackage(), "site-packages"); File[] packages2 = new File[packages.length + 1]; - for (int i = 0;i < packages.length; i++){ - //System.out.println(packages[i].getAbsolutePath()); - packages2[i] = packages[i]; - } + System.arraycopy(packages, 0, packages2, 0, packages.length); packages2[packages.length] = sitePackagesWindows; //System.out.println(sitePackagesWindows.getAbsolutePath()); packages = packages2; diff --git a/datavec/datavec-python/src/main/java/org/datavec/python/PythonProcess.java b/datavec/datavec-python/src/main/java/org/datavec/python/PythonProcess.java index a8ee56510..377603ee2 100644 --- a/datavec/datavec-python/src/main/java/org/datavec/python/PythonProcess.java +++ b/datavec/datavec-python/src/main/java/org/datavec/python/PythonProcess.java @@ -30,9 +30,7 @@ public class PythonProcess { private static String pythonExecutable = Loader.load(org.bytedeco.cpython.python.class); public static String runAndReturn(String... arguments)throws IOException, InterruptedException{ String[] allArgs = new String[arguments.length + 1]; - for (int i = 0; i < arguments.length; i++){ - allArgs[i + 1] = arguments[i]; - } + System.arraycopy(arguments, 0, allArgs, 1, arguments.length); allArgs[0] = pythonExecutable; log.info("Executing command: " + Arrays.toString(allArgs)); ProcessBuilder pb = new ProcessBuilder(allArgs); @@ -45,9 +43,7 @@ public class PythonProcess { public static void run(String... arguments)throws IOException, InterruptedException{ String[] allArgs = new String[arguments.length + 1]; - for (int i = 0; i < arguments.length; i++){ - allArgs[i + 1] = arguments[i]; - } + System.arraycopy(arguments, 0, allArgs, 1, arguments.length); allArgs[0] = pythonExecutable; log.info("Executing command: " + Arrays.toString(allArgs)); ProcessBuilder pb = new ProcessBuilder(allArgs);