Make sure we only create an Iterator during processSelectedKeys(..) if there is really something key to process. This cut down unneeded garbage that needs to get handled by the GC later. See #597
This commit is contained in:
parent
79c33bdfc4
commit
f1e00947a6
@ -456,6 +456,12 @@ abstract class AbstractNioWorker implements Worker {
|
||||
}
|
||||
|
||||
private void processSelectedKeys(Set<SelectionKey> selectedKeys) throws IOException {
|
||||
// check if the set is empty and if so just return to not create garbage by
|
||||
// creating a new Iterator every time even if there is nothing to process.
|
||||
// See https://github.com/netty/netty/issues/597
|
||||
if (selectedKeys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (Iterator<SelectionKey> i = selectedKeys.iterator(); i.hasNext();) {
|
||||
SelectionKey k = i.next();
|
||||
i.remove();
|
||||
|
@ -408,6 +408,12 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
|
||||
}
|
||||
|
||||
private void processSelectedKeys(Set<SelectionKey> selectedKeys) {
|
||||
// check if the set is empty and if so just return to not create garbage by
|
||||
// creating a new Iterator every time even if there is nothing to process.
|
||||
// See https://github.com/netty/netty/issues/597
|
||||
if (selectedKeys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (Iterator<SelectionKey> i = selectedKeys.iterator(); i.hasNext();) {
|
||||
SelectionKey k = i.next();
|
||||
i.remove();
|
||||
|
Loading…
Reference in New Issue
Block a user