Skip to content

Commit

Permalink
socket: optimize reading
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln committed Mar 2, 2017
1 parent abbcba9 commit fb381d2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/transport.socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,9 @@ sock.SocketTransport = SocketTransport;
SocketTransport.prototype._read = function() {
if (!this._readable) return;

let chunk = null;
while ((chunk = this._socket.read()) !== null) {
this._buffer += chunk;
}
const chunk = this._socket.read();
if (chunk === null) return;
this._buffer += chunk;

this._readable = false;

Expand Down

0 comments on commit fb381d2

Please sign in to comment.