All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yann Simon <yann.simon.fr@gmail.com>
To: "Shawn O. Pearce" <spearce@spearce.org>,
	Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [PATCH JGIT] use java 5 like for loops
Date: Sat, 31 Jan 2009 15:19:30 +0100	[thread overview]
Message-ID: <1233411570.7844.13.camel@localhost> (raw)

in for loops that use an iterator or an index (int i), use instead a
loop like: for (Element e : elements)
Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
---
 .../src/org/spearce/jgit/lib/GitIndex.java         |    6 ++----
 .../src/org/spearce/jgit/lib/Repository.java       |    4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
index 6eeccff..920a9c9 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
@@ -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());
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
index e1c4049..038a869 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
@@ -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;
 		}
-- 
1.6.0.6

                 reply	other threads:[~2009-01-31 14:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1233411570.7844.13.camel@localhost \
    --to=yann.simon.fr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=robin.rosenberg@dewire.com \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.