Use IntObjectMap to replace Map in EpollEventLoop.

Motivation:

We need to map from ints to AbstractEpollChannel in EpollEventLoop but there is no need for box to Integer.

Modification:

Replace Map with IntObjectMap.

Result:

No more auto-boxing needed.
This commit is contained in:
Norman Maurer 2014-06-25 20:17:54 +02:00
parent b4b61c1f41
commit c3f24444ef

View File

@ -19,6 +19,8 @@ import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup; import io.netty.channel.EventLoopGroup;
import io.netty.channel.SingleThreadEventLoop; import io.netty.channel.SingleThreadEventLoop;
import io.netty.channel.epoll.AbstractEpollChannel.AbstractEpollUnsafe; import io.netty.channel.epoll.AbstractEpollChannel.AbstractEpollUnsafe;
import io.netty.util.collection.IntObjectHashMap;
import io.netty.util.collection.IntObjectMap;
import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory; import io.netty.util.internal.logging.InternalLoggerFactory;
@ -26,8 +28,6 @@ import io.netty.util.internal.logging.InternalLoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
@ -50,7 +50,7 @@ final class EpollEventLoop extends SingleThreadEventLoop {
private final int epollFd; private final int epollFd;
private final int eventFd; private final int eventFd;
private final Map<Integer, AbstractEpollChannel> ids = new HashMap<Integer, AbstractEpollChannel>(); private final IntObjectMap<AbstractEpollChannel> ids = new IntObjectHashMap<AbstractEpollChannel>();
private final long[] events; private final long[] events;
private int id; private int id;
@ -292,8 +292,8 @@ final class EpollEventLoop extends SingleThreadEventLoop {
Native.epollWait(epollFd, events, 0); Native.epollWait(epollFd, events, 0);
Collection<AbstractEpollChannel> channels = new ArrayList<AbstractEpollChannel>(ids.size()); Collection<AbstractEpollChannel> channels = new ArrayList<AbstractEpollChannel>(ids.size());
for (AbstractEpollChannel ch: ids.values()) { for (IntObjectMap.Entry<AbstractEpollChannel> entry: ids.entries()) {
channels.add(ch); channels.add(entry.value());
} }
for (AbstractEpollChannel ch: channels) { for (AbstractEpollChannel ch: channels) {