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();
List<CommentInfo> match = new ArrayList<CommentInfo>();
List<CommentInfo> other = new ArrayList<CommentInfo>();
for (int i = 0; i < list.size(); i++) {
CommentInfo c = list.get(i);
for (CommentInfo c : list) {
if (c.updated().compareTo(when) <= 0) {
match.add(c);
} else {

View File

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

View File

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

View File

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

View File

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

View File

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