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) { private static List<PoolSubpageMetric> subPageMetricList(PoolSubpage<?>[] pages) {
List<PoolSubpageMetric> metrics = new ArrayList<PoolSubpageMetric>(); List<PoolSubpageMetric> metrics = new ArrayList<PoolSubpageMetric>();
for (int i = 0; i < pages.length; i ++) { for (PoolSubpage<?> head : pages) {
PoolSubpage<?> head = pages[i];
if (head.next == head) { if (head.next == head) {
continue; continue;
} }

View File

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

View File

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

View File

@ -117,8 +117,8 @@ final class Bzip2BlockCompressor {
} }
} }
for (int i = 0; i < condensedInUse.length; i++) { for (boolean isCondensedInUse : condensedInUse) {
writer.writeBoolean(out, condensedInUse[i]); writer.writeBoolean(out, isCondensedInUse);
} }
for (int i = 0; i < condensedInUse.length; i++) { 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) { private boolean ignoreException(Throwable t) {
if (!(t instanceof SSLException) && t instanceof IOException && sslClosePromise.isDone()) { 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 // 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 // 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; return true;
} }

View File

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

View File

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