{"thread":{"id":"17476","subject":"[PATCH JGIT] use java 5 like for loops","startedAt":"2009-01-31T14:19:30Z","lastAt":"2009-01-31T14:19:30Z","messageCount":1,"participants":["Yann Simon"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"102697","messageId":"1233411570.7844.13.camel@localhost","threadId":"17476","inReplyTo":null,"subject":"[PATCH JGIT] use java 5 like for loops","fromName":"Yann Simon","fromEmail":"yann.simon.fr@gmail.com","sentAt":"2009-01-31T14:19:30Z","receivedAt":"2009-01-31T14:19:30Z","isPatch":true,"sender":{"key":"yann.simon.fr@gmail.com","avatar":"https://gravatar.com/avatar/2d926895d27ac988c5c8e591887e5a6a4c7036390403c74fce92519119b887a0?d=mp&s=160"},"body":"in for loops that use an iterator or an index (int i), use instead a\nloop like: for (Element e : elements)\nSigned-off-by: Yann Simon <yann.simon.fr@gmail.com>\n---\n .../src/org/spearce/jgit/lib/GitIndex.java         |    6 ++----\n .../src/org/spearce/jgit/lib/Repository.java       |    4 ++--\n 2 files changed, 4 insertions(+), 6 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java\nb/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java\nindex 6eeccff..920a9c9 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java\n@@ -754,8 +754,7 @@ public Entry addEntry(TreeEntry te) throws\nIOException {\n \t * @throws IOException\n \t */\n \tpublic void checkout(File wd) throws IOException {\n-\t\tfor (Iterator i = entries.values().iterator(); i.hasNext();) {\n-\t\t\tEntry e = (Entry) i.next();\n+\t\tfor (Entry e : entries.values()) {\n \t\t\tif (e.getStage() != 0)\n \t\t\t\tcontinue;\n \t\t\tcheckoutEntry(wd, e);\n@@ -808,8 +807,7 @@ public ObjectId writeTree() throws IOException {\n \t\tStack<Tree> trees = new Stack<Tree>();\n \t\ttrees.push(current);\n \t\tString[] prevName = new String[0];\n-\t\tfor (Iterator i = entries.values().iterator(); i.hasNext();) {\n-\t\t\tEntry e = (Entry) i.next();\n+\t\tfor (Entry e : entries.values()) {\n \t\t\tif (e.getStage() != 0)\n \t\t\t\tcontinue;\n \t\t\tString[] newName = splitDirPath(e.getName());\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java\nb/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java\nindex e1c4049..038a869 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java\n@@ -231,8 +231,8 @@ public File toFile(final AnyObjectId objectId) {\n \t\tString d=n.substring(0, 2);\n \t\tString f=n.substring(2);\n \t\tfinal File[] objectsDirs = objectsDirs();\n-\t\tfor (int i=0; i<objectsDirs.length; ++i) {\n-\t\t\tFile ret = new File(new File(objectsDirs[i], d), f);\n+\t\tfor (File objectsDir : objectsDirs) {\n+\t\t\tFile ret = new File(new File(objectsDir, d), f);\n \t\t\tif (ret.exists())\n \t\t\t\treturn ret;\n \t\t}\n-- \n1.6.0.6\n"}]}