Skip to content

Commit 4ac87be

Browse files
committed
stream: simplify clearBuffer condition
Was doing some unecessary checks.
1 parent 38d9b7f commit 4ac87be

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

lib/_stream_writable.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ function WritableState(options, stream, isDuplex) {
186186
}
187187

188188
ObjectDefineProperties(WritableState.prototype, {
189+
// Backwards compat.
189190
writing: {
190191
get() {
191192
return !!this.writecb;
@@ -323,11 +324,7 @@ Writable.prototype.uncork = function() {
323324
if (state.corked) {
324325
state.corked--;
325326

326-
if (!state.writecb &&
327-
!state.corked &&
328-
!state.bufferProcessing &&
329-
state.bufferedRequest)
330-
clearBuffer(this, state);
327+
clearBuffer(this, state);
331328
}
332329
};
333330

@@ -432,13 +429,7 @@ function onwrite(stream, er) {
432429
onwriteError(stream, state, er, cb);
433430
}
434431
} else {
435-
// Check if we're actually ready to finish, but don't emit yet
436-
const finished = needFinish(state) || stream.destroyed;
437-
438-
if (!finished &&
439-
!state.corked &&
440-
!state.bufferProcessing &&
441-
state.bufferedRequest) {
432+
if (state.bufferedRequest) {
442433
clearBuffer(stream, state);
443434
}
444435

@@ -503,6 +494,13 @@ function errorBuffer(state, err) {
503494

504495
// If there's something in the buffer waiting, then process it
505496
function clearBuffer(stream, state) {
497+
if (state.writecb ||
498+
state.corked ||
499+
state.bufferProcessing ||
500+
!state.bufferedRequest) {
501+
return;
502+
}
503+
506504
state.bufferProcessing = true;
507505
let entry = state.bufferedRequest;
508506

0 commit comments

Comments
 (0)