Skip to contentSkip to conversation

use java 5 like for loops

PATCH New Yann Simon 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore

Yann Simon

author
#0 lore raw

PATCH 1/1 use java 5 like for loops

in for loops that use an iterator or an index (int i), use instead a loop like: for (Element e : elements)

---
 .../src/org/spearce/jgit/lib/GitIndex.java         |    6 ++----
 .../src/org/spearce/jgit/lib/Repository.java       |    4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java index 6eeccff..920a9c9 100644

org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java +0 -0
@@ -754,8 +754,7 @@ public Entry addEntry(TreeEntry te) throws

IOException {
* @throws IOException
*/
public void checkout(File wd) throws IOException {
- for (Iterator i = entries.values().iterator(); i.hasNext();) {
- Entry e = (Entry) i.next();
+ for (Entry e : entries.values()) {
if (e.getStage() != 0)
continue;
checkoutEntry(wd, e);
@@ -808,8 +807,7 @@ public ObjectId writeTree() throws IOException {
Stack<Tree> trees = new Stack<Tree>(); trees.push(current);
String[] prevName = new String[0];
- for (Iterator i = entries.values().iterator(); i.hasNext();) {
- Entry e = (Entry) i.next();
+ for (Entry e : entries.values()) {
if (e.getStage() != 0)
continue;
String[] newName = splitDirPath(e.getName());

(quoted diff) +0 -0

b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index e1c4049..038a869 100644

org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +2 -2
@@ -231,8 +231,8 @@ public File toFile(final AnyObjectId objectId) {
 		String d=n.substring(0, 2);
 		String f=n.substring(2);
 		final File[] objectsDirs = objectsDirs();
-		for (int i=0; i<objectsDirs.length; ++i) {
-			File ret = new File(new File(objectsDirs[i], d), f);
+		for (File objectsDir : objectsDirs) {
+			File ret = new File(new File(objectsDir, d), f);
 			if (ret.exists())
 				return ret;
 		}
Signature · 1 line
1.6.0.6