readable-stream
readable-stream copied to clipboard
Unnecessary 'if' statement ?
In _stream_readable.js, line 359 , why we have to check if state.length === 0 ? Since we have already doRead = true so state.needReadable will be true as well since doRead = state.needReadable , the if statement won't change anything i think. Please correct me if I'm wrong.
Thank you !
else if (doRead) {
debug('do read');
state.reading = true;
state.sync = true;
// if the length is currently zero, then we *need* a readable event.
if (state.length === 0) state.needReadable = true;
// call internal read method
this._read(state.highWaterMark);
state.sync = false;
// If _read pushed data synchronously, then `reading` will be false,
// and we need to re-evaluate how much data we can return to the user.
if (!state.reading) n = howMuchToRead(nOrig, state);