Cleanup : for loops for arrays to make code easier to read and removed unnecessary toLowerCase()

This commit is contained in:
Dmitriy Dumanskiy 2017-02-04 01:08:46 +02:00 committed by Norman Maurer
parent 1a05463c56
commit b9abd3c9fc
7 changed files with 12 additions and 15 deletions

View File

@ -440,8 +440,7 @@ abstract class PoolArena<T> implements PoolArenaMetric {
private static List<PoolSubpageMetric> subPageMetricList(PoolSubpage<?>[] pages) {
List<PoolSubpageMetric> metrics = new ArrayList<PoolSubpageMetric>();
for (int i = 0; i < pages.length; i ++) {
PoolSubpage<?> head = pages[i];
for (PoolSubpage<?> head : pages) {
if (head.next == head) {
continue;
}

View File

@ -448,8 +448,8 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator {
}
int total = 0;
for (int i = 0; i < arenas.length; i++) {
total += arenas[i].numThreadCaches.get();
for (PoolArena<?> arena : arenas) {
total += arena.numThreadCaches.get();
}
return total;

View File

@ -42,8 +42,7 @@ public enum Http2Error {
static {
Http2Error[] errors = Http2Error.values();
Http2Error[] map = new Http2Error[errors.length];
for (int i = 0; i < errors.length; ++i) {
Http2Error error = errors[i];
for (Http2Error error : errors) {
map[(int) error.code()] = error;
}
INT_TO_ENUM_MAP = map;

View File

@ -117,8 +117,8 @@ final class Bzip2BlockCompressor {
}
}
for (int i = 0; i < condensedInUse.length; i++) {
writer.writeBoolean(out, condensedInUse[i]);
for (boolean isCondensedInUse : condensedInUse) {
writer.writeBoolean(out, isCondensedInUse);
}
for (int i = 0; i < condensedInUse.length; i++) {

View File

@ -893,11 +893,11 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
*/
private boolean ignoreException(Throwable t) {
if (!(t instanceof SSLException) && t instanceof IOException && sslClosePromise.isDone()) {
String message = String.valueOf(t.getMessage()).toLowerCase();
String message = t.getMessage();
// first try to match connection reset / broke peer based on the regex. This is the fastest way
// but may fail on different jdk impls or OS's
if (IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
if (message != null && IGNORABLE_ERROR_MESSAGE.matcher(message).matches()) {
return true;
}

View File

@ -134,8 +134,7 @@ final class IovArray implements MessageProcessor {
// No more room!
return false;
}
for (int i = 0; i < buffers.length; i++) {
ByteBuffer nioBuffer = buffers[i];
for (ByteBuffer nioBuffer : buffers) {
int offset = nioBuffer.position();
int len = nioBuffer.limit() - nioBuffer.position();
if (len == 0) {

View File

@ -39,10 +39,10 @@ final class NativeDatagramPacketArray implements ChannelOutboundBuffer.MessagePr
@Override
protected void onRemoval(NativeDatagramPacketArray value) throws Exception {
NativeDatagramPacket[] array = value.packets;
NativeDatagramPacket[] packetsArray = value.packets;
// Release all packets
for (int i = 0; i < array.length; i++) {
array[i].release();
for (NativeDatagramPacket datagramPacket : packetsArray) {
datagramPacket.release();
}
}
};