Skip to content

Commit acf4204

Browse files
committed
[refactor] pass around nil instead of null
since we're pretty much always passing down a buffer
1 parent 864c664 commit acf4204

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/org/jruby/ext/openssl/SSLSocket.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,10 @@ private IRubyObject sysreadImpl(final ThreadContext context, final IRubyObject l
816816
final int length = RubyNumeric.fix2int(len);
817817
final RubyString buffStr;
818818

819-
if ( buff != null && ! buff.isNil() ) {
820-
buffStr = buff.asString();
819+
if ( !buff.isNil() ) {
820+
buffStr = buff.convertToString();
821821
} else {
822-
buffStr = RubyString.newEmptyString(runtime); // fine since we're setValue
822+
buffStr = RubyString.newEmptyString(runtime); // fine since we'll setValue
823823
}
824824
if ( length == 0 ) {
825825
buffStr.clear();
@@ -848,7 +848,7 @@ private IRubyObject sysreadImpl(final ThreadContext context, final IRubyObject l
848848

849849
if ( read == -1 ) {
850850
if ( exception ) throw runtime.newEOFError();
851-
return runtime.getNil();
851+
return context.nil;
852852
}
853853

854854
if ( read == 0 && status == SSLEngineResult.Status.BUFFER_UNDERFLOW ) {
@@ -873,7 +873,7 @@ private IRubyObject sysreadImpl(final ThreadContext context, final IRubyObject l
873873

874874
@JRubyMethod
875875
public IRubyObject sysread(ThreadContext context, IRubyObject len) {
876-
return sysreadImpl(context, len, null, true, true);
876+
return sysreadImpl(context, len, context.nil, true, true);
877877
}
878878

879879
@JRubyMethod
@@ -895,14 +895,14 @@ public IRubyObject sysread(ThreadContext context, IRubyObject[] args) {
895895

896896
@JRubyMethod
897897
public IRubyObject sysread_nonblock(ThreadContext context, IRubyObject len) {
898-
return sysreadImpl(context, len, null, false, true);
898+
return sysreadImpl(context, len, context.nil, false, true);
899899
}
900900

901901
@JRubyMethod
902902
public IRubyObject sysread_nonblock(ThreadContext context, IRubyObject len, IRubyObject arg) {
903903
if ( arg instanceof RubyHash ) { // exception: false
904904
// NOTE: on Ruby 2.3 this is expected to raise a TypeError (but not on 2.2)
905-
return sysreadImpl(context, len, null, false, getExceptionOpt(context, arg));
905+
return sysreadImpl(context, len, context.nil, false, getExceptionOpt(context, arg));
906906
}
907907
return sysreadImpl(context, len, arg, false, true); // buffer arg
908908
}

0 commit comments

Comments
 (0)