Avoid multiple creation of empty array

This commit is contained in:
Emmanuel Bigeon 2018-10-14 09:26:27 -04:00
parent a580133945
commit 7c94dea7b5

View File

@ -139,6 +139,7 @@ public final class ScriptExecution extends Command {
try (InputStreamReader fReader = new InputStreamReader( try (InputStreamReader fReader = new InputStreamReader(
Files.newInputStream(Paths.get(scriptFile)), charset); Files.newInputStream(Paths.get(scriptFile)), charset);
BufferedReader reader = new BufferedReader(fReader)) { BufferedReader reader = new BufferedReader(fReader)) {
String[] emptyArray = new String[0];
while ((cmd = reader.readLine()) != null) { while ((cmd = reader.readLine()) != null) {
lineNo++; lineNo++;
final String cmdLine = readCommandLine(cmd, params); final String cmdLine = readCommandLine(cmd, params);
@ -147,7 +148,7 @@ public final class ScriptExecution extends Command {
} }
final List<String> ps = GCLCConstants.splitCommand(cmdLine); final List<String> ps = GCLCConstants.splitCommand(cmdLine);
final String command = ps.remove(0); final String command = ps.remove(0);
application.executeSub(out, in, command, ps.toArray(new String[0])); application.executeSub(out, in, command, ps.toArray(emptyArray));
} }
} catch (final CommandParsingException e) { } catch (final CommandParsingException e) {
throw new CommandRunException( throw new CommandRunException(