Skip to content

Commit

Permalink
SSLSocket#sysread do not copy bytes from buffer - instead re-use the …
Browse files Browse the repository at this point in the history
…backing array
  • Loading branch information
kares committed Dec 21, 2015
1 parent 2ef7b9c commit 8e894e2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/main/java/org/jruby/ext/openssl/SSLSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -757,10 +757,9 @@ private IRubyObject sysreadImpl(final ThreadContext context,
if ( ex instanceof IRubyObject ) return (IRubyObject) ex; // :wait_readable
}
}
byte[] bytesRead = new byte[read];
dst.position(dst.position() - read);
dst.get(bytesRead);
buffStr.setValue(new ByteList(bytesRead, false));
final byte[] bytesRead = dst.array();
final int offset = dst.position() - read;
buffStr.setValue(new ByteList(bytesRead, offset, read, false));
return buffStr;
}
catch (IOException ioe) {
Expand Down

0 comments on commit 8e894e2

Please sign in to comment.