Skip to content

Commit

Permalink
Cleanup : for loops for arrays to make code easier to read and remove…
Browse files Browse the repository at this point in the history
…d unnecessary toLowerCase()
  • Loading branch information
doom369 authored and normanmaurer committed Feb 6, 2017
1 parent 1a05463 commit b9abd3c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 15 deletions.
3 changes: 1 addition & 2 deletions buffer/src/main/java/io/netty/buffer/PoolArena.java
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ public List<PoolChunkListMetric> chunkLists() {

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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ public int numThreadLocalCaches() {
}

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ private void writeSymbolMap(ByteBuf out) {
}
}

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++) {
Expand Down
4 changes: 2 additions & 2 deletions handler/src/main/java/io/netty/handler/ssl/SslHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -893,11 +893,11 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
*/
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ boolean add(CompositeByteBuf buf) {
// 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ protected NativeDatagramPacketArray initialValue() throws Exception {

@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();
}
}
};
Expand Down

0 comments on commit b9abd3c

Please sign in to comment.