Use jdk 5 for loop
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: I708d82acdf194787e3353699c07244c5ac3de189 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
c0268f899e
commit
6e03645ad8
|
@ -235,17 +235,18 @@ private static boolean recursiveDelete(final File dir,
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
return silent;
|
return silent;
|
||||||
final File[] ls = dir.listFiles();
|
final File[] ls = dir.listFiles();
|
||||||
if (ls != null)
|
if (ls != null) {
|
||||||
for (int k = 0; k < ls.length; k++) {
|
for (File f : ls) {
|
||||||
final File e = ls[k];
|
if (f.isDirectory()) {
|
||||||
if (e.isDirectory())
|
silent = recursiveDelete(f, silent, failOnError);
|
||||||
silent = recursiveDelete(e, silent, failOnError);
|
} else if (!f.delete()) {
|
||||||
else if (!e.delete()) {
|
if (!silent) {
|
||||||
if (!silent)
|
reportDeleteFailure(failOnError, f);
|
||||||
reportDeleteFailure(failOnError, e);
|
}
|
||||||
silent = !failOnError;
|
silent = !failOnError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!dir.delete()) {
|
if (!dir.delete()) {
|
||||||
if (!silent)
|
if (!silent)
|
||||||
reportDeleteFailure(failOnError, dir);
|
reportDeleteFailure(failOnError, dir);
|
||||||
|
|
|
@ -205,8 +205,9 @@ public void testBuildThenClear() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
assertFalse(dc.hasUnmergedPaths());
|
assertFalse(dc.hasUnmergedPaths());
|
||||||
|
|
||||||
|
@ -229,8 +230,9 @@ public void testDetectUnmergedPaths() throws Exception {
|
||||||
ents[2].setFileMode(FileMode.REGULAR_FILE);
|
ents[2].setFileMode(FileMode.REGULAR_FILE);
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
assertTrue(dc.hasUnmergedPaths());
|
assertTrue(dc.hasUnmergedPaths());
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,9 @@ public void testPathFilterGroup_DoesNotSkipTail() throws Exception {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,8 +301,9 @@ public void testAdd_InGitSortOrder() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
assertEquals(paths.length, dc.getEntryCount());
|
assertEquals(paths.length, dc.getEntryCount());
|
||||||
|
@ -351,8 +352,9 @@ public void testBuilderClear() throws Exception {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
}
|
}
|
||||||
assertEquals(paths.length, dc.getEntryCount());
|
assertEquals(paths.length, dc.getEntryCount());
|
||||||
|
|
|
@ -66,8 +66,9 @@ public void testEntriesWithin() throws Exception {
|
||||||
final int aLast = 3;
|
final int aLast = 3;
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
assertEquals(paths.length, dc.getEntryCount());
|
assertEquals(paths.length, dc.getEntryCount());
|
||||||
|
|
|
@ -94,8 +94,9 @@ public void testNoSubtree_NoTreeWalk() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
|
@ -121,8 +122,9 @@ public void testNoSubtree_WithTreeWalk() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
|
@ -154,8 +156,9 @@ public void testSingleSubtree_NoRecursion() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
final String[] expPaths = { "a-", "a", "a0b" };
|
final String[] expPaths = { "a-", "a", "a0b" };
|
||||||
|
@ -200,8 +203,9 @@ public void testSingleSubtree_Recursive() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
final DirCacheIterator i = new DirCacheIterator(dc);
|
final DirCacheIterator i = new DirCacheIterator(dc);
|
||||||
|
@ -236,8 +240,9 @@ public void testTwoLevelSubtree_Recursive() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
try (TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
|
@ -271,8 +276,9 @@ public void testReset() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
DirCacheIterator dci = new DirCacheIterator(dc);
|
DirCacheIterator dci = new DirCacheIterator(dc);
|
||||||
|
@ -365,8 +371,9 @@ public void testBackBug396127() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
DirCacheIterator dci = new DirCacheIterator(dc);
|
DirCacheIterator dci = new DirCacheIterator(dc);
|
||||||
|
@ -398,8 +405,9 @@ public void testTwoLevelSubtree_FilterPath() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
try (TreeWalk tw = new TreeWalk(db)) {
|
try (TreeWalk tw = new TreeWalk(db)) {
|
||||||
|
|
|
@ -102,8 +102,9 @@ public void testSingleSubtree() throws Exception {
|
||||||
final int aLast = 3;
|
final int aLast = 3;
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
assertNull(dc.getCacheTree(false));
|
assertNull(dc.getCacheTree(false));
|
||||||
|
@ -142,8 +143,9 @@ public void testTwoLevelSubtree() throws Exception {
|
||||||
final int acLast = 3;
|
final int acLast = 3;
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
b.finish();
|
b.finish();
|
||||||
|
|
||||||
assertNull(dc.getCacheTree(false));
|
assertNull(dc.getCacheTree(false));
|
||||||
|
@ -198,8 +200,9 @@ public void testWriteReadTree() throws CorruptObjectException, IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
final DirCacheBuilder b = dc.builder();
|
final DirCacheBuilder b = dc.builder();
|
||||||
for (int i = 0; i < ents.length; i++)
|
for (DirCacheEntry ent : ents) {
|
||||||
b.add(ents[i]);
|
b.add(ent);
|
||||||
|
}
|
||||||
|
|
||||||
b.commit();
|
b.commit();
|
||||||
DirCache read = db.readDirCache();
|
DirCache read = db.readDirCache();
|
||||||
|
|
|
@ -173,8 +173,8 @@ private void deinit(String path) throws IOException {
|
||||||
}
|
}
|
||||||
final File[] ls = dir.listFiles();
|
final File[] ls = dir.listFiles();
|
||||||
if (ls != null) {
|
if (ls != null) {
|
||||||
for (int i = 0; i < ls.length; i++) {
|
for (File f : ls) {
|
||||||
FileUtils.delete(ls[i], RECURSIVE);
|
FileUtils.delete(f, RECURSIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,8 +180,8 @@ int getMemoryUsedByLruChainForTest() {
|
||||||
|
|
||||||
int getMemoryUsedByTableForTest() {
|
int getMemoryUsedByTableForTest() {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
for (int i = 0; i < table.length; i++) {
|
for (Entry t : table) {
|
||||||
for (Entry e = table[i]; e != null; e = e.tableNext) {
|
for (Entry e = t; e != null; e = e.tableNext) {
|
||||||
r += e.data.length;
|
r += e.data.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1128,9 +1128,11 @@ private Ref readRef(String name, RefList<Ref> packed) throws IOException {
|
||||||
|
|
||||||
// check whether the found new ref is the an additional ref. These refs
|
// check whether the found new ref is the an additional ref. These refs
|
||||||
// should not go into looseRefs
|
// should not go into looseRefs
|
||||||
for (int i = 0; i < additionalRefsNames.length; i++)
|
for (String additionalRefsName : additionalRefsNames) {
|
||||||
if (name.equals(additionalRefsNames[i]))
|
if (name.equals(additionalRefsName)) {
|
||||||
return n;
|
return n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (looseRefs.compareAndSet(curList, curList.add(idx, n)))
|
if (looseRefs.compareAndSet(curList, curList.add(idx, n)))
|
||||||
modCnt.incrementAndGet();
|
modCnt.incrementAndGet();
|
||||||
|
|
|
@ -109,12 +109,13 @@ void parseHeader() {
|
||||||
final MutableInteger ptr = new MutableInteger();
|
final MutableInteger ptr = new MutableInteger();
|
||||||
ptr.value = nextLF(buf, startOffset, ' ');
|
ptr.value = nextLF(buf, startOffset, ' ');
|
||||||
|
|
||||||
for (int n = 0; n < old.length; n++) {
|
for (CombinedOldImage o : old) {
|
||||||
old[n].startLine = -parseBase10(buf, ptr.value, ptr);
|
o.startLine = -parseBase10(buf, ptr.value, ptr);
|
||||||
if (buf[ptr.value] == ',')
|
if (buf[ptr.value] == ',') {
|
||||||
old[n].lineCount = parseBase10(buf, ptr.value + 1, ptr);
|
o.lineCount = parseBase10(buf, ptr.value + 1, ptr);
|
||||||
else
|
} else {
|
||||||
old[n].lineCount = 1;
|
o.lineCount = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newStartLine = parseBase10(buf, ptr.value + 1, ptr);
|
newStartLine = parseBase10(buf, ptr.value + 1, ptr);
|
||||||
|
|
|
@ -114,39 +114,39 @@ protected void paintCommit(PlotCommit<TLane> commit, int h) {
|
||||||
drawLine(myColor, myLaneX, h, myLaneX, (h + dotSize) / 2,
|
drawLine(myColor, myLaneX, h, myLaneX, (h + dotSize) / 2,
|
||||||
LINE_WIDTH);
|
LINE_WIDTH);
|
||||||
|
|
||||||
for (int i = 0; i < commit.mergingLanes.length; i++) {
|
for (PlotLane mergingLane : commit.mergingLanes) {
|
||||||
final TLane pLane = (TLane) commit.mergingLanes[i];
|
final TLane pLane = (TLane) mergingLane;
|
||||||
final TColor pColor = laneColor(pLane);
|
final TColor pColor = laneColor(pLane);
|
||||||
final int cx = laneC(pLane);
|
final int cx = laneC(pLane);
|
||||||
|
|
||||||
if (Math.abs(myLaneX - cx) > LANE_WIDTH) {
|
if (Math.abs(myLaneX - cx) > LANE_WIDTH) {
|
||||||
final int ix;
|
final int ix;
|
||||||
if (myLaneX < cx)
|
if (myLaneX < cx) {
|
||||||
ix = cx - LANE_WIDTH / 2;
|
ix = cx - LANE_WIDTH / 2;
|
||||||
else
|
} else {
|
||||||
ix = cx + LANE_WIDTH / 2;
|
ix = cx + LANE_WIDTH / 2;
|
||||||
|
}
|
||||||
|
|
||||||
drawLine(pColor, myLaneX, h / 2, ix, h / 2, LINE_WIDTH);
|
drawLine(pColor, myLaneX, h / 2, ix, h / 2, LINE_WIDTH);
|
||||||
drawLine(pColor, ix, h / 2, cx, h, LINE_WIDTH);
|
drawLine(pColor, ix, h / 2, cx, h, LINE_WIDTH);
|
||||||
} else
|
} else
|
||||||
drawLine(pColor, myLaneX, h / 2, cx, h, LINE_WIDTH);
|
drawLine(pColor, myLaneX, h / 2, cx, h, LINE_WIDTH);
|
||||||
|
|
||||||
maxCenter = Math.max(maxCenter, cx);
|
maxCenter = Math.max(maxCenter, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (commit.getChildCount() > 0) {
|
if (commit.getChildCount() > 0) {
|
||||||
for (int i = 0; i < commit.forkingOffLanes.length; i++) {
|
for (PlotLane forkingOffLane : commit.forkingOffLanes) {
|
||||||
final TLane childLane = (TLane) commit.forkingOffLanes[i];
|
final TLane childLane = (TLane) forkingOffLane;
|
||||||
final TColor cColor = laneColor(childLane);
|
final TColor cColor = laneColor(childLane);
|
||||||
final int cx = laneC(childLane);
|
final int cx = laneC(childLane);
|
||||||
if (Math.abs(myLaneX - cx) > LANE_WIDTH) {
|
if (Math.abs(myLaneX - cx) > LANE_WIDTH) {
|
||||||
final int ix;
|
final int ix;
|
||||||
if (myLaneX < cx)
|
if (myLaneX < cx) {
|
||||||
ix = cx - LANE_WIDTH / 2;
|
ix = cx - LANE_WIDTH / 2;
|
||||||
else
|
} else {
|
||||||
ix = cx + LANE_WIDTH / 2;
|
ix = cx + LANE_WIDTH / 2;
|
||||||
|
}
|
||||||
|
|
||||||
drawLine(cColor, myLaneX, h / 2, ix, h / 2, LINE_WIDTH);
|
drawLine(cColor, myLaneX, h / 2, ix, h / 2, LINE_WIDTH);
|
||||||
drawLine(cColor, ix, h / 2, cx, 0, LINE_WIDTH);
|
drawLine(cColor, ix, h / 2, cx, 0, LINE_WIDTH);
|
||||||
|
|
|
@ -323,8 +323,7 @@ private AbstractTreeIterator combineDF(AbstractTreeIterator minRef)
|
||||||
@Override
|
@Override
|
||||||
void popEntriesEqual() throws CorruptObjectException {
|
void popEntriesEqual() throws CorruptObjectException {
|
||||||
final AbstractTreeIterator ch = currentHead;
|
final AbstractTreeIterator ch = currentHead;
|
||||||
for (int i = 0; i < trees.length; i++) {
|
for (AbstractTreeIterator t : trees) {
|
||||||
final AbstractTreeIterator t = trees[i];
|
|
||||||
if (t.matches == ch) {
|
if (t.matches == ch) {
|
||||||
if (t.matchShift == 0)
|
if (t.matchShift == 0)
|
||||||
t.next(1);
|
t.next(1);
|
||||||
|
@ -343,8 +342,7 @@ void popEntriesEqual() throws CorruptObjectException {
|
||||||
@Override
|
@Override
|
||||||
void skipEntriesEqual() throws CorruptObjectException {
|
void skipEntriesEqual() throws CorruptObjectException {
|
||||||
final AbstractTreeIterator ch = currentHead;
|
final AbstractTreeIterator ch = currentHead;
|
||||||
for (int i = 0; i < trees.length; i++) {
|
for (AbstractTreeIterator t : trees) {
|
||||||
final AbstractTreeIterator t = trees[i];
|
|
||||||
if (t.matches == ch) {
|
if (t.matches == ch) {
|
||||||
if (t.matchShift == 0)
|
if (t.matchShift == 0)
|
||||||
t.skip();
|
t.skip();
|
||||||
|
|
|
@ -1338,8 +1338,7 @@ AbstractTreeIterator min() throws CorruptObjectException {
|
||||||
|
|
||||||
void popEntriesEqual() throws CorruptObjectException {
|
void popEntriesEqual() throws CorruptObjectException {
|
||||||
final AbstractTreeIterator ch = currentHead;
|
final AbstractTreeIterator ch = currentHead;
|
||||||
for (int i = 0; i < trees.length; i++) {
|
for (AbstractTreeIterator t : trees) {
|
||||||
final AbstractTreeIterator t = trees[i];
|
|
||||||
if (t.matches == ch) {
|
if (t.matches == ch) {
|
||||||
t.next(1);
|
t.next(1);
|
||||||
t.matches = null;
|
t.matches = null;
|
||||||
|
@ -1349,8 +1348,7 @@ void popEntriesEqual() throws CorruptObjectException {
|
||||||
|
|
||||||
void skipEntriesEqual() throws CorruptObjectException {
|
void skipEntriesEqual() throws CorruptObjectException {
|
||||||
final AbstractTreeIterator ch = currentHead;
|
final AbstractTreeIterator ch = currentHead;
|
||||||
for (int i = 0; i < trees.length; i++) {
|
for (AbstractTreeIterator t : trees) {
|
||||||
final AbstractTreeIterator t = trees[i];
|
|
||||||
if (t.matches == ch) {
|
if (t.matches == ch) {
|
||||||
t.skip();
|
t.skip();
|
||||||
t.matches = null;
|
t.matches = null;
|
||||||
|
@ -1398,10 +1396,8 @@ static String pathOf(byte[] buf, int pos, int end) {
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* a tree type.
|
* a tree type.
|
||||||
*/
|
*/
|
||||||
public <T extends AbstractTreeIterator> T getTree(
|
public <T extends AbstractTreeIterator> T getTree(Class<T> type) {
|
||||||
Class<T> type) {
|
for (AbstractTreeIterator tree : trees) {
|
||||||
for (int i = 0; i < trees.length; i++) {
|
|
||||||
AbstractTreeIterator tree = trees[i];
|
|
||||||
if (type.isInstance(tree)) {
|
if (type.isInstance(tree)) {
|
||||||
return type.cast(tree);
|
return type.cast(tree);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue