Replace 'for' loop with 'foreach'

Change-Id: I5ca01d678b8cf9e9fc75b21270329b483e31694e
This commit is contained in:
alex.ryazantsev
2013-12-04 01:02:53 +04:00
parent 2ede20d73d
commit 05872efbbd
6 changed files with 11 additions and 15 deletions

View File

@@ -177,8 +177,7 @@ class History extends FlowPanel {
Timestamp when = msg.date(); Timestamp when = msg.date();
List<CommentInfo> match = new ArrayList<CommentInfo>(); List<CommentInfo> match = new ArrayList<CommentInfo>();
List<CommentInfo> other = new ArrayList<CommentInfo>(); List<CommentInfo> other = new ArrayList<CommentInfo>();
for (int i = 0; i < list.size(); i++) { for (CommentInfo c : list) {
CommentInfo c = list.get(i);
if (c.updated().compareTo(when) <= 0) { if (c.updated().compareTo(when) <= 0) {
match.add(c); match.add(c);
} else { } else {

View File

@@ -223,8 +223,7 @@ class ProjectDigestFilter implements Filter {
private static String LHEX(byte[] bin) { private static String LHEX(byte[] bin) {
StringBuilder r = new StringBuilder(bin.length * 2); StringBuilder r = new StringBuilder(bin.length * 2);
for (int i = 0; i < bin.length; i++) { for (byte b : bin) {
byte b = bin[i];
r.append(LHEX[(b >>> 4) & 0x0f]); r.append(LHEX[(b >>> 4) & 0x0f]);
r.append(LHEX[b & 0x0f]); r.append(LHEX[b & 0x0f]);
} }

View File

@@ -176,9 +176,9 @@ public class AuthSMTPClient extends SMTPClient {
private String toHex(final byte[] b) { private String toHex(final byte[] b) {
final StringBuilder sec = new StringBuilder(); final StringBuilder sec = new StringBuilder();
for (int i = 0; i < b.length; i++) { for (byte c : b) {
final int u = (b[i] >> 4) & 0xf; final int u = (c >> 4) & 0xf;
final int l = b[i] & 0xf; final int l = c & 0xf;
sec.append(hexchar[u]); sec.append(hexchar[u]);
sec.append(hexchar[l]); sec.append(hexchar[l]);
} }

View File

@@ -70,8 +70,7 @@ public abstract class EmailHeader {
final byte[] encoded = value.getBytes("UTF-8"); final byte[] encoded = value.getBytes("UTF-8");
r.append("=?UTF-8?Q?"); r.append("=?UTF-8?Q?");
for (int i = 0; i < encoded.length; i++) { for (byte b : encoded) {
byte b = encoded[i];
if (b == ' ') { if (b == ' ') {
r.append('_'); r.append('_');

View File

@@ -477,8 +477,8 @@ public class ListProjects implements RestReadView<TopLevelResource> {
} }
private static boolean hasValidRef(List<Ref> refs) { private static boolean hasValidRef(List<Ref> refs) {
for (int i = 0; i < refs.size(); i++) { for (Ref ref : refs) {
if (refs.get(i) != null) { if (ref != null) {
return true; return true;
} }
} }

View File

@@ -455,16 +455,15 @@ public class QueryShell {
} }
int rowCnt = 0; int rowCnt = 0;
final int colCnt = columnMap.length;
while (alreadyOnRow || rs.next()) { while (alreadyOnRow || rs.next()) {
final JsonObject row = new JsonObject(); final JsonObject row = new JsonObject();
final JsonObject cols = new JsonObject(); final JsonObject cols = new JsonObject();
for (int c = 0; c < colCnt; c++) { for (Function function : columnMap) {
String v = columnMap[c].apply(rs); String v = function.apply(rs);
if (v == null) { if (v == null) {
continue; continue;
} }
cols.addProperty(columnMap[c].name.toLowerCase(), v); cols.addProperty(function.name.toLowerCase(), v);
} }
row.addProperty("type", "row"); row.addProperty("type", "row");
row.add("columns", cols); row.add("columns", cols);