Replace for loops with foreach where appropriate
This commit is contained in:
parent
14fa1ef4b6
commit
0425862cd4
|
@ -51,9 +51,8 @@ public class TransactionReceipt {
|
|||
cumulativeGas = cumulativeGasRLP.getRLPData();
|
||||
bloomFilter = new Bloom(bloomRLP.getRLPData());
|
||||
|
||||
for (int i = 0; i < logs.size(); i++) {
|
||||
RLPElement logRLP = logs.get(i);
|
||||
LogInfo logInfo = new LogInfo(logRLP.getRLPData());
|
||||
for (RLPElement log : logs) {
|
||||
LogInfo logInfo = new LogInfo(log.getRLPData());
|
||||
logInfoList.add(logInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,13 +118,13 @@ public class ContractDetails {
|
|||
storageValues = new ArrayList<>();
|
||||
}
|
||||
|
||||
for (int i = 0; i < keys.size(); ++i) {
|
||||
RLPItem rlpItem = (RLPItem) keys.get(i);
|
||||
for (Object key : keys) {
|
||||
RLPItem rlpItem = (RLPItem) key;
|
||||
storageKeys.add(new DataWord(rlpItem.getRLPData()));
|
||||
}
|
||||
|
||||
for (int i = 0; i < values.size(); ++i) {
|
||||
RLPItem rlpItem = (RLPItem) values.get(i);
|
||||
for (Object value : values) {
|
||||
RLPItem rlpItem = (RLPItem) value;
|
||||
storageValues.add(new DataWord(rlpItem.getRLPData()));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,8 @@ public class Helper {
|
|||
// 3. "239472398472" - big number
|
||||
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
for (int i = 0; i < valArray.size(); ++i) {
|
||||
for (Object val : valArray) {
|
||||
|
||||
Object val = valArray.get(i);
|
||||
if (val instanceof String) {
|
||||
|
||||
// Hex num
|
||||
|
|
|
@ -17,9 +17,9 @@ public class Logs {
|
|||
|
||||
public Logs(JSONArray jLogs) {
|
||||
|
||||
for (int i = 0; i < jLogs.size(); ++i) {
|
||||
for (Object jLog1 : jLogs) {
|
||||
|
||||
JSONObject jLog = (JSONObject) jLogs.get(i);
|
||||
JSONObject jLog = (JSONObject) jLog1;
|
||||
byte[] address = Hex.decode((String) jLog.get("address"));
|
||||
byte[] data = Hex.decode(((String) jLog.get("data")).substring(2));
|
||||
|
||||
|
|
|
@ -105,9 +105,9 @@ public class TestCase {
|
|||
post.put(new ByteArrayWrapper(keyBytes), accountState);
|
||||
}
|
||||
|
||||
for (int i = 0; i < callCreates.size(); ++i) {
|
||||
for (Object callCreate : callCreates) {
|
||||
|
||||
CallCreate cc = new CallCreate((JSONObject) callCreates.get(i));
|
||||
CallCreate cc = new CallCreate((JSONObject) callCreate);
|
||||
this.callCreateList.add(cc);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,10 +73,10 @@ public class HelloMessage extends P2pMessage {
|
|||
|
||||
RLPList capabilityList = (RLPList) paramsList.get(3);
|
||||
this.capabilities = new ArrayList<>();
|
||||
for (int i = 0; i < capabilityList.size(); i++) {
|
||||
for (Object aCapabilityList : capabilityList) {
|
||||
|
||||
RLPElement capId = ((RLPList) capabilityList.get(i)).get(0);
|
||||
RLPElement capVersion = ((RLPList) capabilityList.get(i)).get(1);
|
||||
RLPElement capId = ((RLPList) aCapabilityList).get(0);
|
||||
RLPElement capVersion = ((RLPList) aCapabilityList).get(1);
|
||||
|
||||
String name = new String(capId.getRLPData());
|
||||
byte version = capVersion.getRLPData() == null ? 0 : capVersion.getRLPData()[0];
|
||||
|
|
|
@ -209,8 +209,8 @@ public class SerpentCompiler {
|
|||
byte[] lenBytes = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(code.length));
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < lenBytes.length; ++i) {
|
||||
sb.append(lenBytes[i]).append(" ");
|
||||
for (byte lenByte : lenBytes) {
|
||||
sb.append(lenByte).append(" ");
|
||||
}
|
||||
|
||||
// calc real code start position (after the init header)
|
||||
|
|
|
@ -904,9 +904,9 @@ public class RLP {
|
|||
|
||||
copyPos = lenBytes.length + 1;
|
||||
}
|
||||
for (int i = 0; i < elements.length; ++i) {
|
||||
System.arraycopy(elements[i], 0, data, copyPos, elements[i].length);
|
||||
copyPos += elements[i].length;
|
||||
for (byte[] element : elements) {
|
||||
System.arraycopy(element, 0, data, copyPos, element.length);
|
||||
copyPos += element.length;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -156,8 +156,8 @@ public class Value {
|
|||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
if (data[i] > 32 && data[i] < 126) ++readableChars;
|
||||
for (byte aData : data) {
|
||||
if (aData > 32 && aData < 126) ++readableChars;
|
||||
}
|
||||
|
||||
if ((double) readableChars / (double) data.length > 0.55)
|
||||
|
@ -172,10 +172,10 @@ public class Value {
|
|||
int hexChars = 0;
|
||||
byte[] data = (byte[]) value;
|
||||
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
for (byte aData : data) {
|
||||
|
||||
if ((data[i] >= 48 && data[i] <= 57)
|
||||
|| (data[i] >= 97 && data[i] <= 102))
|
||||
if ((aData >= 48 && aData <= 57)
|
||||
|| (aData >= 97 && aData <= 102))
|
||||
++hexChars;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.ethereum.vm;
|
|||
import org.ethereum.core.Bloom;
|
||||
import org.ethereum.crypto.HashUtil;
|
||||
import org.ethereum.util.RLP;
|
||||
import org.ethereum.util.RLPElement;
|
||||
import org.ethereum.util.RLPItem;
|
||||
import org.ethereum.util.RLPList;
|
||||
|
||||
|
@ -36,9 +37,8 @@ public class LogInfo {
|
|||
this.address = address.getRLPData() != null ? address.getRLPData() : new byte[]{};
|
||||
this.data = data.getRLPData() != null ? data.getRLPData() : new byte[]{};
|
||||
|
||||
for (int i = 0; i < topics.size(); ++i) {
|
||||
|
||||
byte[] topic = topics.get(i).getRLPData();
|
||||
for (RLPElement topic1 : topics) {
|
||||
byte[] topic = topic1.getRLPData();
|
||||
this.topics.add(new DataWord(topic));
|
||||
}
|
||||
|
||||
|
|
|
@ -193,9 +193,9 @@ public class ProgramInvokeImpl implements ProgramInvoke {
|
|||
public int countNonZeroData() {
|
||||
|
||||
int counter = 0;
|
||||
for (int i = 0; i < msgData.length; ++i) {
|
||||
for (byte aMsgData : msgData) {
|
||||
|
||||
if (msgData[i] != 0) ++counter;
|
||||
if (aMsgData != 0) ++counter;
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
|
|
@ -154,9 +154,9 @@ public class ProgramInvokeMockImpl implements ProgramInvoke {
|
|||
public int countNonZeroData() {
|
||||
|
||||
int counter = 0;
|
||||
for (int i = 0; i < msgData.length; ++i) {
|
||||
for (byte aMsgData : msgData) {
|
||||
|
||||
if (msgData[i] != 0) ++counter;
|
||||
if (aMsgData != 0) ++counter;
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
|
|
@ -606,9 +606,9 @@ public class TrieTest {
|
|||
// 1. load the data from massive-upload.dmp
|
||||
// which includes deletes/upadtes (5000 operations)
|
||||
TrieImpl trieSingle = new TrieImpl(mockDb_2);
|
||||
for (int i = 0; i < strData.size(); ++i) {
|
||||
for (String aStrData : strData) {
|
||||
|
||||
String[] keyVal = strData.get(i).split("=");
|
||||
String[] keyVal = aStrData.split("=");
|
||||
|
||||
if (keyVal[0].equals("*"))
|
||||
trieSingle.delete(keyVal[1].trim());
|
||||
|
@ -822,9 +822,9 @@ public class TrieTest {
|
|||
|
||||
DatabaseImpl db = new DatabaseImpl("testState");
|
||||
|
||||
for (int i = 0; i < dbDumpJSONArray.size(); ++i) {
|
||||
for (Object aDbDumpJSONArray : dbDumpJSONArray) {
|
||||
|
||||
JSONObject obj = (JSONObject) dbDumpJSONArray.get(i);
|
||||
JSONObject obj = (JSONObject) aDbDumpJSONArray;
|
||||
byte[] key = Hex.decode(obj.get("key").toString());
|
||||
byte[] val = Hex.decode(obj.get("val").toString());
|
||||
|
||||
|
|
Loading…
Reference in New Issue