Skip to content

Commit

Permalink
Eliminate local vars for state mutated elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Dec 4, 2024
1 parent c75709d commit dd6068f
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions core/src/main/java/org/jruby/util/io/SelectExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,13 @@ IRubyObject selectInternal(ThreadContext context) throws IOException {
long i;

RubyArray readAry = null;
IRubyObject read = this.read;
List<ChannelFD> pendingReadFDs = this.pendingReadFDs;
List<ChannelFD> unselectableReadFDs = this.unselectableReadFDs;
if (!read.isNil()) {
readAry = read.convertToArray();
for (i = 0; i < readAry.size(); i++) {
fptr = TypeConverter.ioGetIO(runtime, readAry.eltOk(i)).getOpenFileChecked();
fdSetRead(context, fptr.fd(), readAry.size());
if (fptr.READ_DATA_PENDING() || fptr.READ_CHAR_PENDING()) { /* check for buffered data */
if (pendingReadFDs == null) pendingReadFDs = this.pendingReadFDs = new ArrayList(1);
if (pendingReadFDs == null) pendingReadFDs = new ArrayList(1);
pendingReadFDs.add(fptr.fd());
}
}
Expand All @@ -125,8 +122,6 @@ IRubyObject selectInternal(ThreadContext context) throws IOException {
}

RubyArray writeAry = null;
IRubyObject write = this.write;
List<ChannelFD> unselectableWriteFDs = this.unselectableWriteFDs;
if (!write.isNil()) {
writeAry = write.convertToArray();
for (i = 0; i < writeAry.size(); i++) {
Expand All @@ -140,7 +135,6 @@ IRubyObject selectInternal(ThreadContext context) throws IOException {
}

RubyArray exceptAry = null;
IRubyObject except = this.except;
if (!except.isNil()) {
// This does not actually register anything because we do not have a way to select for error on JDK.
// We make the calls for their side effects.
Expand All @@ -160,7 +154,6 @@ IRubyObject selectInternal(ThreadContext context) throws IOException {
if (n == 0 && pendingReadFDs == null && unselectableReadFDs == null && unselectableWriteFDs == null) return context.nil; /* returns nil on timeout */

RubyArray<?> readReady;
List<SelectionKey> readKeyList = this.readKeyList;
if (readKeyList == null && pendingReadFDs == null && unselectableReadFDs == null) {
readReady = newEmptyArray(context);
} else {
Expand All @@ -180,7 +173,6 @@ IRubyObject selectInternal(ThreadContext context) throws IOException {
}

RubyArray<?> writeReady;
List<SelectionKey> writeKeyList = this.writeKeyList;
if (writeKeyList == null && unselectableWriteFDs == null) {
writeReady = newEmptyArray(context);
} else {
Expand All @@ -200,7 +192,6 @@ IRubyObject selectInternal(ThreadContext context) throws IOException {
}

RubyArray<?> error;
List<SelectionKey> errorKeyList = this.errorKeyList;
if (errorKeyList == null) {
error = newEmptyArray(context);
} else {
Expand Down

0 comments on commit dd6068f

Please sign in to comment.