SelectedSelectionKeySet should only be created if the set can be instrumented

Motivation:

If we can not replace the internal used Set of the Selector there is no need to create an SelectedSelectionKeySet instance.

Modification:

Only create SelectedSelectionKeySet if we will replace the internal set.

Result:

Less object creation in some cases and cleaner code.
This commit is contained in:
时无两丶 2018-05-30 21:33:39 +08:00 committed by Norman Maurer
parent d133bf06a4
commit b53cf045a7

View File

@ -179,8 +179,6 @@ public final class NioEventLoop extends SingleThreadEventLoop {
return new SelectorTuple(unwrappedSelector);
}
final SelectedSelectionKeySet selectedKeySet = new SelectedSelectionKeySet();
Object maybeSelectorImplClass = AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
@ -206,6 +204,7 @@ public final class NioEventLoop extends SingleThreadEventLoop {
}
final Class<?> selectorImplClass = (Class<?>) maybeSelectorImplClass;
final SelectedSelectionKeySet selectedKeySet = new SelectedSelectionKeySet();
Object maybeException = AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override