{"thread":{"id":"17477","subject":"[PATCH JGIT] simplify loop with if and do while","startedAt":"2009-01-31T14:25:09Z","lastAt":"2009-01-31T14:25:09Z","messageCount":1,"participants":["Yann Simon"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"102698","messageId":"1233411909.8213.0.camel@localhost","threadId":"17477","inReplyTo":null,"subject":"[PATCH JGIT] simplify loop with if and do while","fromName":"Yann Simon","fromEmail":"yann.simon.fr@gmail.com","sentAt":"2009-01-31T14:25:09Z","receivedAt":"2009-01-31T14:25:09Z","isPatch":true,"sender":{"key":"yann.simon.fr@gmail.com","avatar":"https://gravatar.com/avatar/2d926895d27ac988c5c8e591887e5a6a4c7036390403c74fce92519119b887a0?d=mp&s=160"},"body":"replace if(condition) { do { } while (condition) } by while (condition)\n{ }\nSigned-off-by: Yann Simon <yann.simon.fr@gmail.com>\n---\n .../src/org/spearce/jgit/lib/Repository.java       |   18\n+++++++-----------\n 1 files changed, 7 insertions(+), 11 deletions(-)\n\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 038a869..b6efac1 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@@ -247,11 +247,9 @@ public File toFile(final AnyObjectId objectId) {\n \tpublic boolean hasObject(final AnyObjectId objectId) {\n \t\tfinal PackFile[] packs = packs();\n \t\tint k = packs.length;\n-\t\tif (k > 0) {\n-\t\t\tdo {\n-\t\t\t\tif (packs[--k].hasObject(objectId))\n-\t\t\t\t\treturn true;\n-\t\t\t} while (k > 0);\n+\t\twhile (k > 0) {\n+\t\t\tif (packs[--k].hasObject(objectId))\n+\t\t\t\treturn true;\n \t\t}\n \t\treturn toFile(objectId).isFile();\n \t}\n@@ -288,12 +286,10 @@ public ObjectLoader openObject(final WindowCursor\ncurs, final AnyObjectId id)\n \t\t\tthrows IOException {\n \t\tfinal PackFile[] packs = packs();\n \t\tint k = packs.length;\n-\t\tif (k > 0) {\n-\t\t\tdo {\n-\t\t\t\tfinal ObjectLoader ol = packs[--k].get(curs, id);\n-\t\t\t\tif (ol != null)\n-\t\t\t\t\treturn ol;\n-\t\t\t} while (k > 0);\n+\t\twhile (k > 0) {\n+\t\t\tfinal ObjectLoader ol = packs[--k].get(curs, id);\n+\t\t\tif (ol != null)\n+\t\t\t\treturn ol;\n \t\t}\n \t\ttry {\n \t\t\treturn new UnpackedObjectLoader(this, id);\n-- \n1.6.0.6\n"}]}