stream: inline onwriteStateUpdate()

The function is very simple and is only called from `onwrite()`.

PR-URL: https://github.com/nodejs/node/pull/27203
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
Luigi Pinca 2019-04-12 18:32:19 +02:00 committed by Daniel Bevenius
parent de463f1490
commit 53e0f632db

View File

@ -442,13 +442,6 @@ function onwriteError(stream, state, sync, er, cb) {
}
}
function onwriteStateUpdate(state) {
state.writing = false;
state.writecb = null;
state.length -= state.writelen;
state.writelen = 0;
}
function onwrite(stream, er) {
const state = stream._writableState;
const sync = state.sync;
@ -457,7 +450,10 @@ function onwrite(stream, er) {
if (typeof cb !== 'function')
throw new ERR_MULTIPLE_CALLBACK();
onwriteStateUpdate(state);
state.writing = false;
state.writecb = null;
state.length -= state.writelen;
state.writelen = 0;
if (er)
onwriteError(stream, state, sync, er, cb);