diff options
author | Carsten Hammer | 2020-06-25 17:33:28 +0000 |
---|---|---|
committer | Carsten Hammer | 2020-07-05 09:36:04 +0000 |
commit | b82d04a5dc2015f195a1fa16717a862547b62553 (patch) | |
tree | 5b4eb70e12e26d7ca9d1f4ef85f32c475b659d21 | |
parent | 820bd18d37bfbea2342736de689b1b42a48f283a (diff) | |
download | eclipse.platform.swt-b82d04a5dc2015f195a1fa16717a862547b62553.tar.gz eclipse.platform.swt-b82d04a5dc2015f195a1fa16717a862547b62553.tar.xz eclipse.platform.swt-b82d04a5dc2015f195a1fa16717a862547b62553.zip |
Use jdk 5 for-each loop
Replace simple uses of Iterator with a corresponding for-loop. Also add
missing braces on loops as necessary. In a number of cases there are
comparisons processed in every loop like i < rectangles.length. I
expect that changing it to the enhanced for loop will be faster.
Change-Id: Ic3fc44cb475e97e423bf7e5c81f76c5e7cc88cc5
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
4 files changed, 14 insertions, 14 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java index 4f88acdbbb..1470f0cf6f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java @@ -209,8 +209,9 @@ int encodeLoop() { } } else { nextPutCode(clearCode); - for (int i = 0; i < nodeStack.length; i++) - nodeStack[i].children = null; + for (LZWNode lzwnode : nodeStack) { + lzwnode.children = null; + } codeSize = bitsPerPixel + 1; codeMask = MASK_TABLE[codeSize - 1]; currentSlot = newCodes; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java index 39b75f4b5a..55c41e999b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/TIFFModifiedHuffmanCodec.java @@ -150,11 +150,11 @@ int decodeRunLength() { boolean found = false; nbrBits = isWhite ? WHITE_MIN_BITS : BLACK_MIN_BITS; code = getNextBits(nbrBits); - for (short[][] element : huffmanCode) { - for (int j = 0; j < element.length; j++) { - if (element[j][0] == code) { + for (short[][] batch : huffmanCode) { + for (short[] element : batch) { + if (element[0] == code) { found = true; - partialRun = element[j][1]; + partialRun = element[1]; if (partialRun == -1) { /* Stop when reaching final EOL on last byte */ if (byteOffsetSrc == src.length - 1) return -1; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java index 389d4c5ce1..0465f2f555 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java @@ -430,8 +430,7 @@ void computeRuns (GC gc) { lineWidth += lineIndent; long hHeap = OS.GetProcessHeap(); int newLineWidth = 0; - for (int j = 0; j < runs[line].length; j++) { - StyleItem item = runs[line][j]; + for (StyleItem item : runs[line]) { int iDx = item.width * wrapWidth / lineWidth; if (iDx != item.width) { item.justify = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, item.glyphCount * 4); @@ -455,9 +454,9 @@ void computeRuns (GC gc) { } lineWidth = getLineIndent(line); - for (int j = 0; j < runs[line].length; j++) { - runs[line][j].x = lineWidth; - lineWidth += runs[line][j].width; + for (StyleItem run1 : runs[line]) { + run1.x = lineWidth; + lineWidth += run1.width; } line++; lineY[line] = lineY[line - 1] + ascentInPoints + descentInPoints + lineSpacingInPoints; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java index 2ac2a8975b..c6c88c56c1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java @@ -449,9 +449,9 @@ void moveRectangles (int xChange, int yChange) { if (yChange > 0 && ((style & SWT.DOWN) == 0)) yChange = 0; if (xChange == 0 && yChange == 0) return; bounds.x += xChange; bounds.y += yChange; - for (int i = 0; i < rectangles.length; i++) { - rectangles [i].x += xChange; - rectangles [i].y += yChange; + for (Rectangle rectangle : rectangles) { + rectangle.x += xChange; + rectangle.y += yChange; } } |