Cleanup: Use foreach whenever is possible

This commit is contained in:
Mathis Chenuet
2015-01-25 18:36:39 +00:00
committed by Laurent Clouet
parent c6dafb3bf6
commit 3ea4107dc1
4 changed files with 12 additions and 13 deletions

View File

@@ -536,8 +536,8 @@ public class Client {
new_env.put("BLENDER_USER_CONFIG", this.config.workingDirectory.getAbsolutePath().replace("\\", "\\\\")); new_env.put("BLENDER_USER_CONFIG", this.config.workingDirectory.getAbsolutePath().replace("\\", "\\\\"));
int index = 0; int index = 0;
for (int i = 0; i < command1.length; i++) { for (String arg : command1) {
if (command1[i].equals(".c")) { if (arg.equals(".c")) {
command[index] = ajob.getScenePath(); command[index] = ajob.getScenePath();
index += 1; index += 1;
command[index] = "-P"; command[index] = "-P";
@@ -563,7 +563,7 @@ public class Client {
} }
script_file.deleteOnExit(); script_file.deleteOnExit();
} }
else if (command1[i].equals(".e")) { else if (arg.equals(".e")) {
command[index] = ajob.getRendererPath(); command[index] = ajob.getRendererPath();
// the number of cores has to be put after the binary and before the scene arg // the number of cores has to be put after the binary and before the scene arg
if (this.config.getNbCores() > 0) { if (this.config.getNbCores() > 0) {
@@ -574,14 +574,14 @@ public class Client {
//index += 1; // do not do it, it will be done at the end of the loop //index += 1; // do not do it, it will be done at the end of the loop
} }
} }
else if (command1[i].equals(".o")) { else if (arg.equals(".o")) {
command[index] = this.config.workingDirectory.getAbsolutePath() + File.separator + ajob.getPrefixOutputImage(); command[index] = this.config.workingDirectory.getAbsolutePath() + File.separator + ajob.getPrefixOutputImage();
} }
else if (command1[i].equals(".f")) { else if (arg.equals(".f")) {
command[index] = ajob.getFrameNumber(); command[index] = ajob.getFrameNumber();
} }
else { else {
command[index] = command1[i]; command[index] = arg;
} }
index += 1; index += 1;
} }

View File

@@ -197,8 +197,7 @@ public class Configuration {
File[] files = dir.listFiles(); File[] files = dir.listFiles();
if (files != null) { if (files != null) {
for (int i = 0; i < files.length; i++) { for (File file : files) {
File file = files[i];
if (file.isDirectory()) { if (file.isDirectory()) {
Utils.delete(file); Utils.delete(file);
} }

View File

@@ -82,9 +82,9 @@ public class Error {
public static ServerCode fromInt(int val) { public static ServerCode fromInt(int val) {
ServerCode[] As = ServerCode.values(); ServerCode[] As = ServerCode.values();
for (int i = 0; i < As.length; i++) { for (ServerCode A : As) {
if (As[i].getValue() == val) { if (A.getValue() == val) {
return As[i]; return A;
} }
} }
return ServerCode.UNKNOWN; return ServerCode.UNKNOWN;

View File

@@ -155,8 +155,8 @@ public class Utils {
if (directory_.isDirectory()) { if (directory_.isDirectory()) {
File[] list = directory_.listFiles(); File[] list = directory_.listFiles();
if (list != null) { if (list != null) {
for (int i = 0; i < list.length; i++) { for (File aFile : list) {
double max1 = lastModificationTime(list[i]); double max1 = lastModificationTime(aFile);
if (max1 > max) { if (max1 > max) {
max = max1; max = max1;
} }